请vb高手,帮助我一下,我将不胜感激。将下列源代码转换成流程图。
PrivateSubText1_LostFocus()DimdbAsConnectionSetdb=NewConnectiondb.CursorLocation=adUs...
Private Sub Text1_LostFocus()
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient
ConnectString = "FileDSN=sysyq.dsn;UID=sa;PWD="
db.Open ConnectString
Set adoPrimaryRS = New Recordset
a = Text1.Text
adoPrimaryRS.Open "select * from jc where 设备编号='" & a & "'", db, adOpenStatic, adLockOptimistic
If adoPrimaryRS.EOF Then
MsgBox "输入的设备编号有错,借出表不存在相应设备!", vbOKOnly + vbExclamation, "警告"
Text1.Text = ""
Text1.SetFocus
Exit Sub
Else
Text2.Text = adoPrimaryRS.Fields("借出单位")
Text3.Text = adoPrimaryRS.Fields("借方经手人")
Text4.Text = adoPrimaryRS.Fields("借出时间")
Text5.Text = adoPrimaryRS.Fields("借出状态")
Text6.Text = adoPrimaryRS.Fields("保管员")
End If 展开
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient
ConnectString = "FileDSN=sysyq.dsn;UID=sa;PWD="
db.Open ConnectString
Set adoPrimaryRS = New Recordset
a = Text1.Text
adoPrimaryRS.Open "select * from jc where 设备编号='" & a & "'", db, adOpenStatic, adLockOptimistic
If adoPrimaryRS.EOF Then
MsgBox "输入的设备编号有错,借出表不存在相应设备!", vbOKOnly + vbExclamation, "警告"
Text1.Text = ""
Text1.SetFocus
Exit Sub
Else
Text2.Text = adoPrimaryRS.Fields("借出单位")
Text3.Text = adoPrimaryRS.Fields("借方经手人")
Text4.Text = adoPrimaryRS.Fields("借出时间")
Text5.Text = adoPrimaryRS.Fields("借出状态")
Text6.Text = adoPrimaryRS.Fields("保管员")
End If 展开
1个回答
展开全部
Private Sub Text1_LostFocus() 'text1失去焦点
Dim db As Connection '定义连接对象
Set db = New Connection '新建连接对象
db.CursorLocation = adUseClient '设置连接对象的属性adUseClient(客户端)
ConnectString = "FileDSN=sysyq.dsn;UID=sa;PWD=" '设置连接对象的属性(通过DSN连接数据库)
db.Open ConnectString '打开数据库
Set adoPrimaryRS = New Recordset 定义记录集
a = Text1.Text 将a赋值
adoPrimaryRS.Open "select * from jc where 设备编号='" & a & "'", db, adOpenStatic, adLockOptimistic 打开记录集查找设备编号等于a的记录
If adoPrimaryRS.EOF Then 判断记录集是否为空,如果为空就执行下面的代码
MsgBox "输入的设备编号有错,借出表不存在相应设备!", vbOKOnly + vbExclamation, "警告"
Text1.Text = ""
Text1.SetFocus
Exit Sub
Else 记录集不为空就将各个文本赋值
Text2.Text = adoPrimaryRS.Fields("借出单位")
Text3.Text = adoPrimaryRS.Fields("借方经手人")
Text4.Text = adoPrimaryRS.Fields("借出时间")
Text5.Text = adoPrimaryRS.Fields("借出状态")
Text6.Text = adoPrimaryRS.Fields("保管员")
Dim db As Connection '定义连接对象
Set db = New Connection '新建连接对象
db.CursorLocation = adUseClient '设置连接对象的属性adUseClient(客户端)
ConnectString = "FileDSN=sysyq.dsn;UID=sa;PWD=" '设置连接对象的属性(通过DSN连接数据库)
db.Open ConnectString '打开数据库
Set adoPrimaryRS = New Recordset 定义记录集
a = Text1.Text 将a赋值
adoPrimaryRS.Open "select * from jc where 设备编号='" & a & "'", db, adOpenStatic, adLockOptimistic 打开记录集查找设备编号等于a的记录
If adoPrimaryRS.EOF Then 判断记录集是否为空,如果为空就执行下面的代码
MsgBox "输入的设备编号有错,借出表不存在相应设备!", vbOKOnly + vbExclamation, "警告"
Text1.Text = ""
Text1.SetFocus
Exit Sub
Else 记录集不为空就将各个文本赋值
Text2.Text = adoPrimaryRS.Fields("借出单位")
Text3.Text = adoPrimaryRS.Fields("借方经手人")
Text4.Text = adoPrimaryRS.Fields("借出时间")
Text5.Text = adoPrimaryRS.Fields("借出状态")
Text6.Text = adoPrimaryRS.Fields("保管员")
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询