VB电子相册

时间:2018-07-04 14:57:32
【文件属性】:

文件名称:VB电子相册

文件大小:5.72MB

文件格式:RAR

更新时间:2018-07-04 14:57:32

VB电子相册

VB电子相册 电子相册 1、数据库连接 Public conn As ADODB.Connection Public Sub conDB() Set conn = New ADODB.Connection conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _ & App.Path & "\data\pic.mdb" conn.Open End Sub 2、登录模块 Dim loginTimes As Integer Private rsmc As ADODB.Recordset Private rs As ADODB.Recordset Public userName As String Private Sub cmdExit_Click() Unload Me End Sub Private Sub cmdOK_Click() Call login End Sub Private Sub Form_Activate() Call conDB Set rsmc = New ADODB.Recordset rsmc.CursorLocation = adUseClient rsmc.Open "用户信息表", conn, 0, 1 'need to learn cbUserName.Clear While Not rsmc.EOF cbUserName.AddItem rsmc.Fields("用户名") rsmc.MoveNext Wend cbUserName.SetFocus tbPwd.Text = "" cbUserName.Refresh End Sub Private Sub Form_Unload(Cancel As Integer) conn.Close Set rs = Nothing End Sub Sub login() Dim strSql As String userName = "" If Trim(cbUserName.Text) = "" Then MsgBox "用户名不用为空,请选择用户名!", vbOKOnly + vbExclamation, "警告" cbUserName.SetFocus Else strSql = "select * from 用户信息表 where 用户名='" & Trim(cbUserName.Text) & "'" Set rs = New ADODB.Recordset rs.Open strSql, conn, 2, 2 If Trim(rs.Fields("密码")) = Trim(tbPwd.Text) Then rs.Close Me.Hide userName = Trim(cbUserName.Text) 'Load frmMain frmMain.Show Exit Sub Else MsgBox "密码不对,请重新输入!", vbOKOnly + vbExclamation, "警告" tbPwd.Text = "" tbPwd.SetFocus End If loginTimes = loginTimes + 1 If loginTimes = 3 Then MsgBox "密码错误已有3次,你不能进入系统!", vbOKOnly + vbQuestion, "提示" Unload Me End If End If End Sub 3、主模块 Private rs As ADODB.Recordset Dim stuNum As Integer Private Sub Form_Activate() Call conDB End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) conn.Close Set conn = Nothing End Sub Private Sub mnuAddPic_Click() frmAddPic.Show End Sub Private Sub mnuDeletePic_Click() frmDeletePic.Show End Sub Private Sub mnuShowpic_Click() frmShow.Show End Sub Private Sub mnuExit_Click() Unload Me End End Sub Private Sub mnuSMPic_Click() frmSMPic.Show End Sub Private Sub mnuUser_Click() Dim frm1 As New frmUser frm1.Show End Sub 4、显示图片模块 Dim str As String Dim rs As ADODB.Recordset Dim rsNum As Integer Dim nextNum As Integer Private Sub cbPic_Click() str = App.Path + "\" Set rs = New ADODB.Recordset Dim strConn As String strConn = "select * from pic where name='" + Trim(cbPic.Text) + "'" rs.Open strConn, conn, 0, 1 str = str + rs.Fields("address").Value 'MsgBox str Image1.Picture = LoadPicture(str) rs.Close End Sub Private Sub CmdNext_Click() nextNum = nextNum + 1 'MsgBox nextNum If nextNum > rsNum - 1 Then nextNum = 0 'MsgBox nextNum End If Dim temp As Integer temp = nextNum Set rs = New ADODB.Recordset rs.Open "pic", conn, 0, 1 ' rs.MoveFirst ' While Not rs.EOF And temp > 0 ' 'rs.MoveNext ' 'temp = temp - 1' ' Wend rs.Move (temp) str = App.Path + "\" str = str + rs.Fields("address").Value cbPic.Text = rs.Fields("name").Value Image1.Picture = LoadPicture(str) rs.Close End Sub Private Sub Form_Load() Call conDB str = App.Path + "\" nextNum = 0 Set rs = New ADODB.Recordset rs.Open "pic", conn, 0, 1 str = str + rs.Fields("address").Value Image1.Picture = LoadPicture(str) cbPic.Clear rsNum = 0 'MsgBox rsNum rs.MoveFirst While Not rs.EOF cbPic.AddItem rs.Fields("name") rsNum = rsNum + 1 rs.MoveNext Wend cbPic.Text = "tu1" rs.Close End Sub


【文件预览】:
电子相册2
----frmLogin.log(108B)
----frmMain.log(253B)
----frmLogin.frm(5KB)
----pic()
--------tu3.jpg(51KB)
--------2.jpg(59KB)
--------6.jpg(75KB)
--------555555.jpg(50KB)
--------5.jpg(70KB)
--------4.jpg(99KB)
--------10.jpg(35KB)
--------10 - 副本.jpg(35KB)
--------如燕.jpg(126KB)
--------bj 003.jpg(2.6MB)
--------9.jpg(49KB)
--------7.jpg(54KB)
--------bj 001.jpg(2.45MB)
----Module1.bas(266B)
----电子相册.exe(88KB)
----frmUser.log(598B)
----data()
--------pic.ldb(448B)
--------pic.mdb(356KB)
----工程1.vbp(1KB)
----frmUser.frm(10KB)
----frmSMPic.frm(8KB)
----MSSCCPRJ.SCC(190B)
----frmNewUser.frm(6KB)
----frmMain.frm(3KB)
----frmDeletePic.frm(3KB)
----frmAddPic.frm(3KB)
----工程1.vbw(468B)
----电子相册2.doc(41KB)
----frmShow.frm(4KB)
----frmNewUser.log(55B)

网友评论