VB 为什么form2中,limit没有携带任何值?

Dim a As Integer, TextLine As String
a = 0
Open "d:\test.txt" For Input As #1 '打开密码本
Do While Not EOF(1) '循环至文件尾
a = a + 1
Line Input #1, TextLine '读入一行数据并将其赋予变量TextLine
If TextLine = cz Then '如果这行内容和要查找的内容一样
    n = a
    Exit Do
End If
Loop
Close #1
End Function
Private Sub Command1_Click()
Dim tname As String, tpassword As String
Dim i As Integer
Dim flag1 As Integer, flag2 As Integer
flag1 = -1
flag2 = -1
n = -1
tname = Text1(0)
tpassword = Text2(1)
If Text1(0).Text <> "" Then
    If Text2(1).Text <> "" Then
        i = 0
        Srh (tname)
        If n <> "-1" Then
            flag1 = 1
        End If
        n = -1
        Srh (tpassword)
        If n <> "-1" Then
            flag2 = 1
        End If
        If flag1 = 1 And flag2 = 1 Then
            If tname = Adm Then
                limit = 0
            End If
            If tname <> "Adm" Then
                limit = 1
            End If
            Me.Hide
            Form2.Show
            Form2.Caption = "主界面"
        End If
        
        Close #1
    End If
End If
 'Print #1, "Hello world!" 向文件中打印Hello World

 Close #1
End Sub
Private Sub Command2_CLick()
    x = MsgBox("你确定要退出吗?", vbYesNo, "提示")
    If x = vbYes Then
    End
    End If
End Sub
Private Sub Command3_Click()
Me.Hide
Form3.Show
Form3.Caption = "注册新用户"
End Sub

Private Sub Command4_Click()
Me.Hide
Form4.Show
Form4.Caption = "修改密码"
End Sub

Private Sub Form_Load()
    limit = -1
    Me.Caption = "请输入用户名和密码"
    Command1.Caption = "确定"
    Command2.Caption = "退出"
    Command3.Caption = "注册新用户"
    Command4.Caption = "修改密码"
    Label1.Caption = "用户名"
    Label2.Caption = "密码"
    Text1(0).Text = ""
    Text2(1).Text = ""
    
End Sub

_________________________________________

‘Form2:

Private Sub Form_Load()
    Command1.Caption = "查询"
    Command2.Caption = "录入"
    Command3.Caption = "退出"
    If limit = 0 Then
        Text1.Text = "当前为管理员模式"
    End If
    If limit = 1 Then
        Text1.Text = "当前为普通用户模式"
    End If
End Sub


 

要把limit定义为模块成员变量或者全局变量