File VB6-无效调用或过程(运行时错误5)

File VB6-无效调用或过程(运行时错误5),file,vb6,runtime,File,Vb6,Runtime,我目前正在做我的大学项目,遇到了一个障碍 我不太确定我在这里哪里出错了,因为这段代码在以前的项目中工作,所有变量名都已正确更新和检查 代码如下: Private Sub Login() Dim User As UserRecord 'Sets the type as the record Dim UserChannel As Integer 'Channel for User file Dim UserRecordPointer As Integer 'Sets the record point

我目前正在做我的大学项目,遇到了一个障碍

我不太确定我在这里哪里出错了,因为这段代码在以前的项目中工作,所有变量名都已正确更新和检查

代码如下:

Private Sub Login()
Dim User As UserRecord 'Sets the type as the record
Dim UserChannel As Integer 'Channel for User file
Dim UserRecordPointer As Integer 'Sets the record pointer for the User file as a whole number
Dim FoundAtLeastOneRecord As Boolean 'Declares the finding of a record as a binary digit (True or False)

UserFile = App.Path + "\GMP_TSS_DATA\user_data.dat"
FoundAtLeastOneRecord = False
UserRecordPointer = 1
UserChannel = FreeFile
Open UserFile For Random As UserChannel Len = UserLength
Get UserChannel, UserRecordPointer, User
Do While Not EOF(UserChannel)
    If Trim(User.Username) = Trim(TxtOfficerInformationLoginUsername.Text) And Trim(User.Password) = Trim(TxtOfficerInformationLoginPassword.Text) Then
        FrmOfficerInformation.Show
        FrmMainMenu.Hide
        Unload Me
        FoundAtLeastOneRecord = True
    Else
        MsgBox "The username and password you entered do not match. Please try again.", vbInformation, "Incorrect username or password"
    End If
    UserRecordPointer = UserRecordPointer + 1
    Get UserChannel, UserRecordPointer, User
Loop
Close UserChannel
If FoundAtLeastOneRecord = False Then 'If no records could be found then a message box will appear informing the user that this is the case.
    MsgBox ("A user profile could not be found. Please back-up and then delete the 'GMP_TSS_DATA' folder and restart the software."), vbExclamation, "Critical Error!"
End If
End Sub
用户文件位于名为GMP_TSS_DATA的文件夹中,该文件夹是在运行应用程序的根目录中创建的

单击登录按钮后出现的错误是运行时错误5:调用或过程无效


我会感激所有能得到的帮助

请尝试从此行中删除左括号和右括号:MsgBox找不到用户配置文件。请备份并删除“GMP\U TSS\U数据”文件夹,然后重新启动软件。VBEQUOTION,严重错误!如果UserLength=0,则会出现该错误。另外,如果UserLength是一个局部变量,则不定义它。如果这是真的,那么在表单代码的第一行添加显式选项。这告诉编译器需要变量声明,这是一个很好的实践。谢谢@jac。我把它放进去了,但拼写错了选项Expilcit,只是一个输入错误,但我从来没有注意到!谢谢