3

Whenever I use Application.InputBox() I bring up VBA Help to remind me which Type to use:

Sub MAIN()
    Dim s As String

    s = Application.InputBox(Prompt:="enter data", Type:=2)
End Sub

Does there exist, or can I create an Enumeration for Type so I could code like:

Sub MAIN()
    Dim s As String

    s = Application.InputBox(Prompt:="enter data", Type:=vbString)
End Sub

It would be easier for me to remember an Enumeration rather than an arbitrary integer.

2 Answers 2

5

No there isn't, but you can just create an enumeration by yourself:

Public Enum InputBoxType
    ibtFormula = 0
    ibtNumber = 1
    ibtText = 2
    ibtBoolean = 4
    ibtRange = 8
    ibtError = 16
    ibtArray = 64
End Enum
Sign up to request clarification or add additional context in comments.

2 Comments

Can also have combinations like this: ibtNumOrText = 1 + 2
Sure but then you would have to add 64 values to the enum for all combinations (ibtFormula appears to be implicitely included because it's zero). It makes much more sense to use ibtNumber + ibtText in the code.
0

Using IntelliSense

As the main intention seems to be fastening inputs without consulting extra help, I'd propose to benefit from using IntelliSense:

Simply start input within a code module by

vba.VbVarType.

or in the immediate window by

?vba.VbVarType.

and choose the proposed DropDown values:

Using Intellisense

Alternatively you could have a look into the Object Browser, too giving a better overview.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.