一,【前言】
机房收费系统也敲了一段时间了,一直没有做总结,为了把自己做的过程和思路分享出来,小遍就把这篇学会生查询余额的总结分享出来。
二,【流程图】
三,【感受】
其实这部分也是在机房里最简单的一部分,在做的过程中只要理清思路,把代码中的字母敲对就基本没什么问题,还有就是在做这部分的时候需要调用那个数据表,在运行时是否能把这个表调用出来,调用前有没有把数据存入到库里。在这个窗体中调用的是:student_info“,这个表也是我们在做机房的时候用到的最多的一个表。
四,【代码】
> Private Sub cmdInpuiry_Click()
> Dim txtSQL As String
> Dim mrc As ADODB.Recordset
> Dim MsgText As String
>
> '判断卡号是否输入
>
> If Trim(txtCardNo.Text = "") Then
> MsgBox "请输入用户名!", vbOKOnly + vbExclamation, "警告"
> txtCardNo.SetFocus
> Else
>
>
> If Not IsNumeric(txtCardNo.Text) Then
> MsgBox "请输入数字!", vbOKOnly + vbExclamation, "警告"
> Exit Sub
> txtCardNo.SetFocus
> Else
>
> '判断卡号是否存在
>
> txtSQL = "select * from student_info where cardno = '" & txtCardNo.Text & "'"
> Set mrc = ExecuteSQL(txtSQL, MsgText)
>
> If mrc.EOF Then
> MsgBox "卡号不存在,请重新输入卡号!", vbOKOnly + vbExclamation, "警告"
> txtCardNo.SetFocus
> txtCardNo.Text = ""
>
> Else
>
>
> '如果卡号正确,则进入查询
>
> txtSID.Text = mrc.Fields(1)
> txtName.Text = mrc.Fields(2)
> txtSex.Text = mrc.Fields(3)
> txtDept.Text = mrc.Fields(4)
> txtGrade.Text = mrc.Fields(5)
> txtClass.Text = mrc.Fields(6)
> txtstatus.Text = mrc.Fields(10)
> txtExplain.Text = mrc.Fields(8)
> txtBalance.Text = mrc.Fields(7)
>
>
> End If
>
> mrc.Close
>
> End If
> End If
> End Sub
最后运行结果的结果。