急求vb高手,帮我翻译一下代码!!!越详细越好!!谢谢 啦!! 50
添加车辆信息窗体的代码具体如下:OptionExplicitDimmblChangeAsBooleanDimmrcAsADODB.RecordsetPublictxtSQ...
添加车辆信息窗体的代码具体如下:
Option Explicit
Dim mblChange As Boolean
Dim mrc As ADODB.Recordset
Public txtSQL As String
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdSave_Click()
Dim intCount As Integer
Dim sMeg As String
Dim MsgText As String
For intCount = 0 To 3
If Trim(txtItem(intCount) & " ") = "" Then
Select Case intCount
Case 0
sMeg = "车号"
Case 1
sMeg = "类型"
Case 2
sMeg = "车主"
Case 3
sMeg = "发动机号"
End Select
sMeg = sMeg & "不能为空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(intCount).SetFocus
Exit Sub
End If
Next intCount
For intCount = 6 To 7
If Not IsNumeric(txtItem(intCount)) Then
MsgBox "请输入数字!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
Next intCount
If Trim(txtItem(8) & "") <> "" Then
If Not IsDate(txtItem(8)) Then
MsgBox "登记时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
txtItem(8).SetFocus
Exit Sub
Else
txtItem(8) = Format(txtItem(8), "yyyy-mm-dd")
End If
End If
If Trim(txtItem(9) & "") <> "" Then
If Not IsDate(txtItem(9)) Then
MsgBox "发证时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
txtItem(9).SetFocus
Exit Sub
Else
txtItem(9) = Format(txtItem(9), "yyyy-mm-dd")
End If
End If '添加判断是否有相同的ID记录
txtSQL = "select * from vehicle where clid='" & Trim(txtItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
MsgBox "已经存在此车号的记录!", vbOKOnly + vbExclamation, "警告"
txtItem(0).SetFocus
Exit Sub
End If
mrc.Close '再加入新记录
txtSQL = "select * from vehicle"
Set mrc = ExecuteSQL(txtSQL, MsgText)
mrc.AddNew
mrc.Fields(0) = Trim(txtItem(0))
For intCount = 1 To 11
mrc.Fields(intCount) = Trim(txtItem(intCount))
Next intCount
mrc.Update
MsgBox "保存成功!", vbOKOnly, "信息提示!"
mrc.Close
For intCount = 0 To 11
txtItem(intCount) = ""
Next intCount
mblChange = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
gintvMode = 0
End Sub
Private Sub txtItem_Change(Index As Integer)
'有变化设置gblchange
mblChange = True
End Sub
Private Sub txtItem_GotFocus(Index As Integer)
txtItem(Index).SelStart = 0
txtItem(Index).SelLength = Len(txtItem(Index))
End Sub
Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
EnterToTab KeyCode
End Sub 展开
Option Explicit
Dim mblChange As Boolean
Dim mrc As ADODB.Recordset
Public txtSQL As String
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdSave_Click()
Dim intCount As Integer
Dim sMeg As String
Dim MsgText As String
For intCount = 0 To 3
If Trim(txtItem(intCount) & " ") = "" Then
Select Case intCount
Case 0
sMeg = "车号"
Case 1
sMeg = "类型"
Case 2
sMeg = "车主"
Case 3
sMeg = "发动机号"
End Select
sMeg = sMeg & "不能为空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(intCount).SetFocus
Exit Sub
End If
Next intCount
For intCount = 6 To 7
If Not IsNumeric(txtItem(intCount)) Then
MsgBox "请输入数字!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
Next intCount
If Trim(txtItem(8) & "") <> "" Then
If Not IsDate(txtItem(8)) Then
MsgBox "登记时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
txtItem(8).SetFocus
Exit Sub
Else
txtItem(8) = Format(txtItem(8), "yyyy-mm-dd")
End If
End If
If Trim(txtItem(9) & "") <> "" Then
If Not IsDate(txtItem(9)) Then
MsgBox "发证时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
txtItem(9).SetFocus
Exit Sub
Else
txtItem(9) = Format(txtItem(9), "yyyy-mm-dd")
End If
End If '添加判断是否有相同的ID记录
txtSQL = "select * from vehicle where clid='" & Trim(txtItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
MsgBox "已经存在此车号的记录!", vbOKOnly + vbExclamation, "警告"
txtItem(0).SetFocus
Exit Sub
End If
mrc.Close '再加入新记录
txtSQL = "select * from vehicle"
Set mrc = ExecuteSQL(txtSQL, MsgText)
mrc.AddNew
mrc.Fields(0) = Trim(txtItem(0))
For intCount = 1 To 11
mrc.Fields(intCount) = Trim(txtItem(intCount))
Next intCount
mrc.Update
MsgBox "保存成功!", vbOKOnly, "信息提示!"
mrc.Close
For intCount = 0 To 11
txtItem(intCount) = ""
Next intCount
mblChange = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
gintvMode = 0
End Sub
Private Sub txtItem_Change(Index As Integer)
'有变化设置gblchange
mblChange = True
End Sub
Private Sub txtItem_GotFocus(Index As Integer)
txtItem(Index).SelStart = 0
txtItem(Index).SelLength = Len(txtItem(Index))
End Sub
Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
EnterToTab KeyCode
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询