输入框值得到双重整数

时间:2018-01-11 17:40:52

标签: vba excel-vba excel

我有一个输入框,我通常在其中输入值,但是当我从1-9输入数字时,它取10-90,因为我给出的条件是如果输入框值大于50则显示错误消息。

当我输入no 6时,我才知道它显示错误信息。当我检查代码中的输入值时,它仍然是1 -9。

可能是什么错误?

inp = InputBox("enter turning angle")

'textbox 1 value is 50
If inp < Sheets("Four Bar").TextBox1.Value Or inp = Sheets("Four Bar").TextBox1.Value Then
    ''my code ''
Else
    MsgBox "Max inner wheel angle is" & " " & Sheets("Four Bar").TextBox1.Value
End If

1 个答案:

答案 0 :(得分:0)

<强> UNTESTED:

Dim inp As Long
inp = Application.InputBox(prompt:="enter turning angle", Type:=1)

'textbox 1 value is 50
If inp < CLng(Sheets("Four Bar").TextBox1.Value) Or inp = CLng(Sheets("Four Bar").TextBox1.Value) Then
    ''my code ''
Else
    MsgBox "Max inner wheel angle is" & " " & Sheets("Four Bar").TextBox1.Value
End If

只是为了确保我们正在处理数字