| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1533 人关注过本帖
标题:我用VB做了一个人事软件,但是一调试就出现未定义变量,请高手看看,这倒底 ...
只看楼主 加入收藏
good165169
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-11-27
结帖率:0
收藏
已结贴  问题点数:20 回复次数:5 
我用VB做了一个人事软件,但是一调试就出现未定义变量,请高手看看,这倒底是怎么回事
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
搜索更多相关主题的帖子: 人事 软件 employee False 
2012-11-27 20:08
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4947
专家分:30084
注 册:2008-10-15
收藏
得分:10 
哪一行报错,哪个变量报未定义啊?

让大家直接分析静态代码,考验吗?

授人于鱼,不如授人于渔
早已停用QQ了
2012-11-28 08:12
good165169
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-11-27
收藏
得分:0 
Public Sub showemployee()
一编译就报错,然后上面这个代码就成黄色的了
2012-11-28 23:08
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4947
专家分:30084
注 册:2008-10-15
收藏
得分:0 
你执行一下,看看到这个函数里,具体报哪个 变量没有定义。

你这个函数是一个 需要多次调用的函数。一执行就能发现错误提示。

授人于鱼,不如授人于渔
早已停用QQ了
2012-11-29 09:23
Artless
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:103
帖 子:4211
专家分:28888
注 册:2009-4-8
收藏
得分:10 
Public Sub showemployee()
dim i as long

无知
2012-11-29 14:12
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4947
专家分:30084
注 册:2008-10-15
收藏
得分:0 
以下是引用Artless在2012-11-29 14:12:11的发言:

Public Sub showemployee()
dim i as long



他 i 定义是全局变量。
估计是 控件的名字有问题。

授人于鱼,不如授人于渔
早已停用QQ了
2012-11-29 14:33
快速回复:我用VB做了一个人事软件,但是一调试就出现未定义变量,请高手看看,这 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029840 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved