——————————————————————————
对所有窗口整体的理解:
frmAbout:获取系统信息。
frmfrmAddclassinfo---frmAdduser:添加信息。
frmInquireresult---frmInquiresinfo:查询信息
frmModifyclassinfo---frmModifyuserinfo:修改信息
————————————————————————————
数据库核心:
Dim mrc As ADODB.Recordset
If Not Testtxt(txtName.Text) Then
'防止输入框为空
MsgBox "提示信息", vbOKOnly + vbExclamation, "警告"’vbOKOnly + vbExclamation意为点击ok继续执行程序
txtName.SetFocus'为空获得焦点继续输入
Exit Sub
End If’通过上述一系列的含有if条件的自定义函数的输入添加各类信息
mrc.AddNew
mrc.Fields(0) = Trim(txtClassno.Text)
mrc.Fields(1) = Trim(txtClassno.Text)
mrc.Fields(2) = Trim(txtClassno.Text)
mrc.Fields(3) = Trim(txtClassno.Text)
mrc.Update
mrc.Close
MsgBox "添加班级信息成功!", vbOKOnly + vbExclamation, "警告"
Private Sub deleteCommand_Click()
myBookmark = mrc.Bookmark'标记
str2$ = MsgBox("是否删除当前记录?", vbOKCancel, "删除当前记录")
If str2$ = vbOK Then'$代表string msgbox返回的是数值,ok返回1,cancel返回2
mrc.MoveNext'移到下一个记录
If mrc.EOF Then'移动后如果记录在Recordest对象的最后一个记录之后
mrc.MoveFirst'则移动到第一个
myBookmark = mrc.Bookmark'进行标记
mrc.MoveLast'移动到最后一个
mrc.Delete'删除
mrc.Bookmark = myBookmark'标记
Call viewData'显示记录
Else
myBookmark = mrc.Bookmark
mrc.MovePrevious
mrc.Delete
mrc.Bookmark = myBookmark
Call viewData
End If
Else
mrc.Bookmark = myBookmark
Call viewData
End If
End Sub
Private Sub editCommand_Click()
'不可查看的前提下
mcclean = False
'不可查看
Frame2.Enabled = False
firstCommand.Enabled = False
previousCommand.Enabled = False
nextCommand.Enabled = False
lastCommand.Enabled = False
'可以修改
txtCourseno.Enabled = True
txtCoursename.Enabled = True
comboCoursetype.Enabled = True
txtCoursedes.Enabled = True
comboCoursetype.AddItem "必修"
comboCoursetype.AddItem "考查"
'标记
myBookmark = mrc.Bookmark
End Sub
——————————————————————————————Private Sub cmdInquire_Click()
Dim txtSQL As String
Dim MsgText As String
Dim dd(4) As Boolean
Dim mrc As ADODB.Recordset
txtSQL = "select * from student_Info where "'得到SQL语句
'分别利用学号,姓名,班号进行查询
'学号
'————————————————————————————
If Check1(0).Value Then
If Trim(txtSID.Text) = "" Then
sMeg = "学号不能为空"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtSID.SetFocus
Exit Sub
Else
If Not IsNumeric(Trim(txtSID.Text)) Then
MsgBox "请输入数字!", vbOKOnly + vbExclamation, "警告"
Exit Sub
txtSID.SetFocus
End If
dd(0) = True
txtSQL = txtSQL & "student_ID = '" & Trim(txtSID.Text) & "'"
End If
End If
frmLogin窗口的解释:
这是一个比较典型的登录窗口
Private Sub Form_Load()
Dim sBuffer As String
Dim lSize As Long
sBuffer = Space$(255) 'sBuffer为255个空格字符串
lSize = Len(sBuffer) ‘sBuffer串的长度
Call GetUserName(sBuffer, lSize) 'GetUserName是为了读取用户名到sBuffer中If lSize > 0 Then ’如果用户名长度大于0
txtUserName.Text = Left$(sBuffer, lSize) ‘取用户名
Else ’否则
txtUserName.Text = vbNullString ‘sBuffer '为空字符串
End If
End Sub
Private Sub cmdCancel_Click()
OK = False ’登录失败
Me.Hide ‘隐藏窗口
End Sub
得到某一程序的安装路径:API函数
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long