主题:生成EXE时候出现编译错误变量未定义
Option Explicit
Public cuTabCh As Boolean
Public cutable As String
Public cuAp As Integer '当前指针位置
Dim i As Integer
Public Pwin As String
Public Sub showemployee()
DataA.RecordSource = "select * from employee"
DataA.Refresh
DBGA.Columns("性别").Button = True
DBGA.Columns("学历").Button = True
DBGA.Columns("部门").Button = True
For i = 0 To 2
Mtab(i).Checked = False
Next i
Mtab(0).Checked = True
cutable = "employee"
cuTabCh = True
End Sub
Public Sub showleave()
DataA.RecordSource = "select * from leave"
DataA.Refresh
For i = 0 To 2
Mtab(i).Checked = False
Next i
Mtab(1).Checked = True
cutable = "leave"
cuTabCh = True
End Sub
Public Sub showsalary()
DataA.RecordSource = "select * from salary"
DataA.Refresh
For i = 0 To 2
Mtab(i).Checked = False
Next i
Mtab(2).Checked = True
cutable = "salary"
cuTabCh = True
End Sub
Private Sub Form_Load()
Dim fil, tbcount, i As Integer
Dim Tbstr(50), Tbnam(50) As String
DataA.DatabaseName = App.Path + "\sm.mdb"
DataB.DatabaseName = App.Path + "\sm.mdb"
DataB.RecordSource = "select * from employee"
Call showemployee
If Dir(App.Path + "\table.ini") = "" Then
LsDegree.AddItem "定制"
LsDepart.AddItem "定制"
Else
fil = FreeFile()
Open App.Path + "\table.ini" For Input As #fil
Do While Not EOF(fil)
Input #fil, Tbnam(i), Tbstr(i)
i = i + 1
Loop
Close #fil
tbcount = i
For i = 0 To tbcount
If Tbnam(i) = "lsdegree" Then
LsDegree.AddItem Tbstr(i)
ElseIf Tbnam(i) = "lsdepart" Then
LsDepart.AddItem Tbstr(i)
End If
Next i
LsDegree.AddItem "定制"
LsDepart.AddItem "定制"
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub DBGA_ButtonClick(ByVal ColIndex As Integer)
Dim Co As Column
Set Co = DBGA.Columns(ColIndex)
Select Case ColIndex
Case 4
Lssex.Left = DBGA.Left + Co.Left + Co.Width
Lssex.Top = DBGA.Top + DBGA.RowTop(DBGA.Row)
Lssex.Visible = True
Lssex.ZOrder 0
Lssex.SetFocus
Case 7 'degree
LsDegree.Left = DBGA.Left + Co.Left + Co.Width
LsDegree.Top = DBGA.Top + DBGA.RowTop(DBGA.Row)
LsDegree.Visible = True
LsDegree.ZOrder 0
LsDegree.SetFocus
Case 8 'department
LsDepart.Left = DBGA.Left + Co.Left + Co.Width
LsDepart.Top = DBGA.Top + DBGA.RowTop(DBGA.Row)
LsDepart.Visible = True
LsDepart.ZOrder 0
LsDepart.SetFocus
End Select
End Sub
Private Sub DBGA_HeadClick(ByVal ColIndex As Integer)
DBGA.ClearSelCols
End Sub
Private Sub DBGA_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
FrmMain.PopupMenu Mp
End If
End Sub
Private Sub DBGA_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
cuAp = DataA.Recordset.AbsolutePosition
If cuAp > -1 Then
DataB.Recordset.FindFirst "职工编号=" + CStr(DataA.Recordset.Fields("职工编号"))
If DataB.Recordset.NoMatch Then
Lab.Caption = "没有此职员"
Else
With DataB.Recordset
Lab.Caption = "工号:" + CStr(.Fields(0)) + " 姓名:" + CStr(.Fields(1)) + " 性别:" + CStr(.Fields(4)) + " 部门:" + CStr(.Fields(8)) + " 职位:" + CStr(.Fields(9)) + " 电话:" + CStr(.Fields(11))
End With
End If
End If
End Sub
Private Sub LsDegree_Click()
If LsDegree.Text = "定制" Then
FrmTable.Show
Else
DataA.Recordset.Edit
DataA.Recordset.Fields(7) = LsDegree.Text
DataA.Recordset.Fields(13) = CStr(frmLogin.CurId)
DataA.Recordset.Fields(14) = CStr(Now)
DataA.Recordset.Update
DataB.Refresh
End If
End Sub
Private Sub LsDepart_Click()
If LsDepart.Text = "定制" Then
FrmTable.Show
Else
DataA.Recordset.Edit
DataA.Recordset.Fields(8) = LsDepart.Text
DataA.Recordset.Fields(13) = CStr(frmLogin.CurId)
DataA.Recordset.Fields(14) = CStr(Now)
DataA.Recordset.Update
DataB.Refresh
End If
End Sub
Private Sub Lssex_Click()
DataA.Recordset.Edit
DataA.Recordset.Fields(4) = Lssex.Text
DataA.Recordset.Fields(13) = CStr(frmLogin.CurId)
DataA.Recordset.Fields(14) = CStr(Now)
DataA.Recordset.Update
DataB.Refresh
End Sub
'#################################
Private Sub Lssex_LostFocus()
Lssex.Visible = False
End Sub
Private Sub Lsdegree_LostFocus()
LsDegree.Visible = False
End Sub
Private Sub Lsdepart_LostFocus()
LsDepart.Visible = False
End Sub
Private Sub DBGA_Scroll(Cancel As Integer)
Lssex.Visible = False
LsDegree.Visible = False
LsDepart.Visible = False
End Sub
'#################################
Private Sub MAbout_Click()
frmAbout.Show
End Sub
Private Sub Mhelp_Click()
FrmHelp.Show
End Sub
Private Sub Moption_Click(Index As Integer)
If Index = 0 Then
If frmLogin.CurUser = "root" Then
FrmSys.Show
Else
FrmPsw.Show
Pwin = "Frmmain"
FrmMain.Enabled = False
End If
Else
End
End If
End Sub
Private Sub Mpop_Click(Index As Integer)
Select Case Index
Case 1
FrmEdit.Show
FrmMain.Enabled = False
Case 2
If DBGA.SelBookmarks.Count = 1 Then
If MsgBox("确定要删除吗?", vbOKCancel, "确定") = vbOK Then DataA.Recordset.Delete
cuAp = 0
Else
MsgBox "请选择要删除的条目!"
End If
Case 3
FrmSearch.Show
End Select
End Sub
Private Sub Mtab_Click(Index As Integer)
Dim i As Integer
For i = 0 To 2
Mtab(i).Checked = False
Next i
Mtab(Index).Checked = True
Select Case Index
Case 0
Call showemployee
Case 1
Call showleave
Case 2
Call showsalary
End Select
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Index
Case 1 'edit
FrmEdit.Show
FrmMain.Enabled = False
Case 2 'del
If DBGA.SelBookmarks.Count = 1 Then
If MsgBox("确定要删除吗?", vbOKCancel, "确定") = vbOK Then DataA.Recordset.Delete
cuAp = 0
Else
MsgBox "请选择要删除的条目!"
End If
Case 3 'seek
FrmSearch.Show
Case 4 'setup
FrmSetup.Show
End Select
End Sub
Private Sub Toolbar2_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Index
Case 1
Call showemployee
Case 2
Call showleave
Case 3
Call showsalary
Case 4
If frmLogin.CurUser = "root" Then
FrmSys.Show
Else
FrmPsw.Show
Pwin = "Frmmain"
FrmMain.Enabled = False
End If
End Select
End Sub
Public cuTabCh As Boolean
Public cutable As String
Public cuAp As Integer '当前指针位置
Dim i As Integer
Public Pwin As String
Public Sub showemployee()
DataA.RecordSource = "select * from employee"
DataA.Refresh
DBGA.Columns("性别").Button = True
DBGA.Columns("学历").Button = True
DBGA.Columns("部门").Button = True
For i = 0 To 2
Mtab(i).Checked = False
Next i
Mtab(0).Checked = True
cutable = "employee"
cuTabCh = True
End Sub
Public Sub showleave()
DataA.RecordSource = "select * from leave"
DataA.Refresh
For i = 0 To 2
Mtab(i).Checked = False
Next i
Mtab(1).Checked = True
cutable = "leave"
cuTabCh = True
End Sub
Public Sub showsalary()
DataA.RecordSource = "select * from salary"
DataA.Refresh
For i = 0 To 2
Mtab(i).Checked = False
Next i
Mtab(2).Checked = True
cutable = "salary"
cuTabCh = True
End Sub
Private Sub Form_Load()
Dim fil, tbcount, i As Integer
Dim Tbstr(50), Tbnam(50) As String
DataA.DatabaseName = App.Path + "\sm.mdb"
DataB.DatabaseName = App.Path + "\sm.mdb"
DataB.RecordSource = "select * from employee"
Call showemployee
If Dir(App.Path + "\table.ini") = "" Then
LsDegree.AddItem "定制"
LsDepart.AddItem "定制"
Else
fil = FreeFile()
Open App.Path + "\table.ini" For Input As #fil
Do While Not EOF(fil)
Input #fil, Tbnam(i), Tbstr(i)
i = i + 1
Loop
Close #fil
tbcount = i
For i = 0 To tbcount
If Tbnam(i) = "lsdegree" Then
LsDegree.AddItem Tbstr(i)
ElseIf Tbnam(i) = "lsdepart" Then
LsDepart.AddItem Tbstr(i)
End If
Next i
LsDegree.AddItem "定制"
LsDepart.AddItem "定制"
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub DBGA_ButtonClick(ByVal ColIndex As Integer)
Dim Co As Column
Set Co = DBGA.Columns(ColIndex)
Select Case ColIndex
Case 4
Lssex.Left = DBGA.Left + Co.Left + Co.Width
Lssex.Top = DBGA.Top + DBGA.RowTop(DBGA.Row)
Lssex.Visible = True
Lssex.ZOrder 0
Lssex.SetFocus
Case 7 'degree
LsDegree.Left = DBGA.Left + Co.Left + Co.Width
LsDegree.Top = DBGA.Top + DBGA.RowTop(DBGA.Row)
LsDegree.Visible = True
LsDegree.ZOrder 0
LsDegree.SetFocus
Case 8 'department
LsDepart.Left = DBGA.Left + Co.Left + Co.Width
LsDepart.Top = DBGA.Top + DBGA.RowTop(DBGA.Row)
LsDepart.Visible = True
LsDepart.ZOrder 0
LsDepart.SetFocus
End Select
End Sub
Private Sub DBGA_HeadClick(ByVal ColIndex As Integer)
DBGA.ClearSelCols
End Sub
Private Sub DBGA_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
FrmMain.PopupMenu Mp
End If
End Sub
Private Sub DBGA_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
cuAp = DataA.Recordset.AbsolutePosition
If cuAp > -1 Then
DataB.Recordset.FindFirst "职工编号=" + CStr(DataA.Recordset.Fields("职工编号"))
If DataB.Recordset.NoMatch Then
Lab.Caption = "没有此职员"
Else
With DataB.Recordset
Lab.Caption = "工号:" + CStr(.Fields(0)) + " 姓名:" + CStr(.Fields(1)) + " 性别:" + CStr(.Fields(4)) + " 部门:" + CStr(.Fields(8)) + " 职位:" + CStr(.Fields(9)) + " 电话:" + CStr(.Fields(11))
End With
End If
End If
End Sub
Private Sub LsDegree_Click()
If LsDegree.Text = "定制" Then
FrmTable.Show
Else
DataA.Recordset.Edit
DataA.Recordset.Fields(7) = LsDegree.Text
DataA.Recordset.Fields(13) = CStr(frmLogin.CurId)
DataA.Recordset.Fields(14) = CStr(Now)
DataA.Recordset.Update
DataB.Refresh
End If
End Sub
Private Sub LsDepart_Click()
If LsDepart.Text = "定制" Then
FrmTable.Show
Else
DataA.Recordset.Edit
DataA.Recordset.Fields(8) = LsDepart.Text
DataA.Recordset.Fields(13) = CStr(frmLogin.CurId)
DataA.Recordset.Fields(14) = CStr(Now)
DataA.Recordset.Update
DataB.Refresh
End If
End Sub
Private Sub Lssex_Click()
DataA.Recordset.Edit
DataA.Recordset.Fields(4) = Lssex.Text
DataA.Recordset.Fields(13) = CStr(frmLogin.CurId)
DataA.Recordset.Fields(14) = CStr(Now)
DataA.Recordset.Update
DataB.Refresh
End Sub
'#################################
Private Sub Lssex_LostFocus()
Lssex.Visible = False
End Sub
Private Sub Lsdegree_LostFocus()
LsDegree.Visible = False
End Sub
Private Sub Lsdepart_LostFocus()
LsDepart.Visible = False
End Sub
Private Sub DBGA_Scroll(Cancel As Integer)
Lssex.Visible = False
LsDegree.Visible = False
LsDepart.Visible = False
End Sub
'#################################
Private Sub MAbout_Click()
frmAbout.Show
End Sub
Private Sub Mhelp_Click()
FrmHelp.Show
End Sub
Private Sub Moption_Click(Index As Integer)
If Index = 0 Then
If frmLogin.CurUser = "root" Then
FrmSys.Show
Else
FrmPsw.Show
Pwin = "Frmmain"
FrmMain.Enabled = False
End If
Else
End
End If
End Sub
Private Sub Mpop_Click(Index As Integer)
Select Case Index
Case 1
FrmEdit.Show
FrmMain.Enabled = False
Case 2
If DBGA.SelBookmarks.Count = 1 Then
If MsgBox("确定要删除吗?", vbOKCancel, "确定") = vbOK Then DataA.Recordset.Delete
cuAp = 0
Else
MsgBox "请选择要删除的条目!"
End If
Case 3
FrmSearch.Show
End Select
End Sub
Private Sub Mtab_Click(Index As Integer)
Dim i As Integer
For i = 0 To 2
Mtab(i).Checked = False
Next i
Mtab(Index).Checked = True
Select Case Index
Case 0
Call showemployee
Case 1
Call showleave
Case 2
Call showsalary
End Select
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Index
Case 1 'edit
FrmEdit.Show
FrmMain.Enabled = False
Case 2 'del
If DBGA.SelBookmarks.Count = 1 Then
If MsgBox("确定要删除吗?", vbOKCancel, "确定") = vbOK Then DataA.Recordset.Delete
cuAp = 0
Else
MsgBox "请选择要删除的条目!"
End If
Case 3 'seek
FrmSearch.Show
Case 4 'setup
FrmSetup.Show
End Select
End Sub
Private Sub Toolbar2_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Index
Case 1
Call showemployee
Case 2
Call showleave
Case 3
Call showsalary
Case 4
If frmLogin.CurUser = "root" Then
FrmSys.Show
Else
FrmPsw.Show
Pwin = "Frmmain"
FrmMain.Enabled = False
End If
End Select
End Sub