我创建了一个用户窗体,我在其中输入了一个数字或名称,然后它将基于此查找一些信息。如果输入是数字,它调用子 OpslagNummer 并传递来自 UserForm 的输入。问题是它总是在某些数字 fx 61001 或 56001 上给我一个“溢出”错误,其中 10001 工作得很好?
UserFrom 1中的代码:
Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift
As Integer)
If KeyCode = 13 Then
UserForm1.Hide
TextInput = TextBox1.Value
UserForm1.TextBox1 = ""
TextInput = 61001 '----Hardcoded number for the sake of debugging
If IsNumeric(TextInput) = True Then
Call OpslagNummer(TextInput)
Else
If Len(TextInput) >= 3 Then
Call OpslagNavn(TextInput)
Else
End
End If
End If
End If
End Sub
模块 1 中的代码:
Sub OpslagNummer(ByVal TextBoxNumber As Integer)
'Code that looks up the information
End Sub