【求助】一段VB代码编译错误。。。
请高手看下这段代码有什么问题?我一编译就出现“Else没有If”等警告,,反正我就是生成不了工程,我该什么办?请高手帮忙修改下。。谢谢了!Dim czylxbj As String '操作员类型比较变量
Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Command1.SetFocus
KeyAscii = 0
End Sub
Private Sub Command1_Click()
If Combo1.Text = "" Then
MsgBox "请选择操作员类型"
Combo1.SetFocus
Else
If Trim(Combo1.Text) = czylxbj Then
czyxm = Text2.Text
czylx = Combo1.Text
Unload Me
main.Show
Else
MsgBox "对不起!您不是" + Trim(Combo1.Text) + ",请正确选择您的职务。"
Combo1.Text = ""
Combo1.SetFocus
End If
End If
Else
If Trim(Combo1.Text) = "" Then
Combo1.Text = ""
main.Show
MsgBox "操作员姓名或操作员密码不正确,请重新登录"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Combo1.Text = ""
Text1.SetFocus
End If
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Combo1.Text = ""
Text1.SetFocus
End Sub
Private Sub Command3_Click()
End
End Sub
On Error GoTo er
'If Dir("c:\windows\ywxxgl\yyglzc.ini") = "" Then
' RmDir "c:\windows\ywxxgl"
' MkDir "c:\windows\ywxxgl"
' zcm = InputBox("请输入系统注册号码?")
' If zcm <> " " Then
' MsgBox "系统注册号码不合法!禁止使用本系统!"
' End
' End If
' Open "c:\windows\ywxxgl\yyglzc.ini" For Output As #1
' Print #1, zcm
' Close #1
' MsgBox "系统注册成功!请重新启动系统"
' End
'End If
'If Dir("c:\windows\ywxxgl\yyglzc.ini") <> "" Then
' Open "c:\windows\ywxxgl\yyglzc.ini" For Input As #2
' Input #2, zcm1
' Close #2
' If zcm1 <> " " Then
' MsgBox "系统注册信息出现严重错误,导致系统不能正常使用!"
' End
' End If
'End If
If Dir(App.Path + "dl.zkf") = "" Then
k = MsgBox("系统数据库名或服务器路径未指定,现在指定吗?", vbYesNo)
If k = 6 Then
cd1.FileName = ""
cd1.ShowOpen
If Right(cd1.FileName, 11) = "docter.yygl" Then
Open App.Path + "dl.zkf" For Output As #1
Print #1, cd1.FileName
Close #1
dbstr = cd1.FileName
Else
MsgBox "选择服务器路径或文件名错误!请重新登录!"
End
End If
Else
End
End If
Else
Open App.Path + "dl.zkf" For Input As #2
Input #2, dbstr
Close #2
End If
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Combo1.Text = ""
Text1.SetFocus
Data1.DatabaseName = dbstr
Data1.RecordSource = "czy"
Data1.Refresh
Exit Sub
er:
Select Case Err.Number
Case 76
MkDir "c:\windows\ywxxgl"
MsgBox "系统路径初始化设置成功!请重新启动系统进行系统注册!"
Case -2147467259
MsgBox "服务器未启动或连接不成功,请检查服务器连接情况。!然后重新启动系统!"
Case Else
MsgBox "系统出现未知错误!被迫停止运行!"
End Select
End
End Sub
Private Sub Text1_Change()
If Len(Text1.Text) >= 2 Then
Data1.Refresh
Data1.Recordset.FindFirst "操作员代码=" + "'" + Text1.Text + "'"
If Data1.Recordset.NoMatch = True Then
MsgBox "操作员代码不存在,请重新输入"
Text1.Text = ""
Text1.SetFocus
Exit Sub
Else
Text2.Text = Data1.Recordset.Fields(1)
czystr = Text2.Text
czylxbj = Data1.Recordset.Fields(3)
Text3.SetFocus
End If
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Combo1.SetFocus
End If
End Sub