谁能帮我解释一下这段vb代码(详解+感谢) 20
影碟出租(frmRentDisk):OptionExplicitPublicsqlStrAsStringPublicmsgTextAsStringPublicuserNo...
影碟出租(frmRentDisk):
Option Explicit
Public sqlStr As String
Public msgText As String
Public userNo As String
Private Sub cmdOK_Click()
If verifyUser(txtMemberNo.Text) = True Then
CmdOk.Enabled = False
txtMemberNo.Enabled = False
userNo = txtMemberNo.Text
cmdRent.Enabled = True
End If
End Sub
Private Sub cmdRent_Click()
LendDisk
cmdSave.Enabled = True
End Sub
Private Sub cmdSave_Click()
saveDisks
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub Form_Load()
'窗体居中显示
Me.Top = (Screen.Height - Me.Height) \ 2
Me.Left = (Screen.Width - Me.Width) \ 2
initTable
cmdRent.Enabled = False
cmdSave.Enabled = False
End Sub
Sub initTable()
Dim i As Integer
fgRent.Rows = 1
fgRent.Cols = 5
'设定行高
For i = 0 To fgRent.Rows - 1
fgRent.RowHeight(i) = 280
Next i
'设定列的属性
fgRent.Row = 0
For i = 0 To fgRent.Cols - 1
fgRent.Col = i '指定当前列为第i列
fgRent.FixedAlignment(i) = 4 '每列内容居中显示
Select Case i
Case 0
fgRent.ColWidth(i) = 600 '设定列宽
fgRent.Text = "序号"
Case 1
fgRent.ColWidth(i) = 1200 '设定列宽
fgRent.Text = "影碟编号"
Case 2
fgRent.ColWidth(i) = 2200 '设定列宽
fgRent.Text = "影碟名称"
Case 3
fgRent.ColWidth(i) = 1000 '设定列宽
fgRent.Text = "会员编号"
Case 4
fgRent.ColWidth(i) = 800 '设定列宽
fgRent.Text = "数量"
End Select
Next i
End Sub
Sub LendDisk()
Dim rs As ADODB.Recordset
Dim i As Integer
Dim j As Integer
If txtDiskNo.Text = "" Then
MsgBox "请填写影碟编号!", vbExclamation, "提示"
Exit Sub
End If
sqlStr = "select * from disks where [no]=" & txtDiskNo.Text
Set rs = ExecuteSQL(sqlStr, msgText)
If rs.RecordCount = 0 Then
MsgBox "没有查找满足条件的数据!", vbExclamation, "提示"
Else
txtDiskNo.Text = ""
lblTotal.Caption = Val(lblTotal.Caption) + 1
fgRent.Rows = fgRent.Rows + 1
fgRent.RowHeight(fgRent.Rows - 1) = 280
fgRent.Row = fgRent.Rows - 1
For j = 0 To fgRent.Cols - 1
fgRent.Col = j '设置当前为列为第j列
fgRent.CellAlignment = 4 '每列内容居中显示
Select Case j
Case 0
fgRent.Text = fgRent.Rows - 1
Case 1
fgRent.Text = rs.Fields("no")
Case 4
fgRent.Text = "1"
End Select
Next j
End If
rs.Close
End Sub 展开
Option Explicit
Public sqlStr As String
Public msgText As String
Public userNo As String
Private Sub cmdOK_Click()
If verifyUser(txtMemberNo.Text) = True Then
CmdOk.Enabled = False
txtMemberNo.Enabled = False
userNo = txtMemberNo.Text
cmdRent.Enabled = True
End If
End Sub
Private Sub cmdRent_Click()
LendDisk
cmdSave.Enabled = True
End Sub
Private Sub cmdSave_Click()
saveDisks
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub Form_Load()
'窗体居中显示
Me.Top = (Screen.Height - Me.Height) \ 2
Me.Left = (Screen.Width - Me.Width) \ 2
initTable
cmdRent.Enabled = False
cmdSave.Enabled = False
End Sub
Sub initTable()
Dim i As Integer
fgRent.Rows = 1
fgRent.Cols = 5
'设定行高
For i = 0 To fgRent.Rows - 1
fgRent.RowHeight(i) = 280
Next i
'设定列的属性
fgRent.Row = 0
For i = 0 To fgRent.Cols - 1
fgRent.Col = i '指定当前列为第i列
fgRent.FixedAlignment(i) = 4 '每列内容居中显示
Select Case i
Case 0
fgRent.ColWidth(i) = 600 '设定列宽
fgRent.Text = "序号"
Case 1
fgRent.ColWidth(i) = 1200 '设定列宽
fgRent.Text = "影碟编号"
Case 2
fgRent.ColWidth(i) = 2200 '设定列宽
fgRent.Text = "影碟名称"
Case 3
fgRent.ColWidth(i) = 1000 '设定列宽
fgRent.Text = "会员编号"
Case 4
fgRent.ColWidth(i) = 800 '设定列宽
fgRent.Text = "数量"
End Select
Next i
End Sub
Sub LendDisk()
Dim rs As ADODB.Recordset
Dim i As Integer
Dim j As Integer
If txtDiskNo.Text = "" Then
MsgBox "请填写影碟编号!", vbExclamation, "提示"
Exit Sub
End If
sqlStr = "select * from disks where [no]=" & txtDiskNo.Text
Set rs = ExecuteSQL(sqlStr, msgText)
If rs.RecordCount = 0 Then
MsgBox "没有查找满足条件的数据!", vbExclamation, "提示"
Else
txtDiskNo.Text = ""
lblTotal.Caption = Val(lblTotal.Caption) + 1
fgRent.Rows = fgRent.Rows + 1
fgRent.RowHeight(fgRent.Rows - 1) = 280
fgRent.Row = fgRent.Rows - 1
For j = 0 To fgRent.Cols - 1
fgRent.Col = j '设置当前为列为第j列
fgRent.CellAlignment = 4 '每列内容居中显示
Select Case j
Case 0
fgRent.Text = fgRent.Rows - 1
Case 1
fgRent.Text = rs.Fields("no")
Case 4
fgRent.Text = "1"
End Select
Next j
End If
rs.Close
End Sub 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询