我有一个代码,要求输入1-3之间使用InputBox
然后运行一个代码取决于它是什么输入。我的问题是,我不需要InputBox
了,因为我打算做的工作只使用一个输入,它是3.我试图删除输入框,并在那里插入3,但然后代码不做任何事情。然后我试图在框中插入一个默认值,但它仍然出现,需要我点击输入,这是我想要避免的。请问我该如何解决这个问题。取消或隐藏输入框在vba
我的代码
Function GetTypeFile() As Integer
Dim strInput As String, strMsg As String
Dim Default
choice = 0
While (choice < 1 Or choice > 3)
Default = "3"
strMsg = "Type in the kind of entities to create (1 for points, 2 for points and splines, 3 for points, splines and loft):"
strInput = InputBox(Prompt:=strMsg, _
Title:="User Info", Default:=3, XPos:=2000, YPos:=2000)
'Validation of the choice
choice = CInt(strInput)
If (choice < 1 Or choice > 3) Then
MsgBox "Invalid value: must be 1, 2 or 3"
End If
Wend
GetTypeFile = choice
End Function
如果你总是把'3'放在什么位置,你想要什么来代替'InputBox'? 'GetTypeFile'将会是'3'。 –
这就是问题所在,当我试图消除'InputBox'的代码,然后不做任何事情。当我试图直接将值分配给'GetTypeFile'时,它仍然不起作用。 –
所以你想要这个代码做什么?你想如何输入1到3的输入? –