Home > Developments, IT, Solved problems > Custom InputBox for VBA, MS Access, Excel

Custom InputBox for VBA, MS Access, Excel

Since the modern dialog box, we’ve thought why not make modern InputBox? Oh, this time there are tones of examples on the web about custom InputBox for VBA. So what’s the point?

Well the convenience is you have a component collection and you can have variety of components in one place. besides, most custom inputboxes on the internet look cool but to be true modal, they will secretly use a infinite loop with DoEvents in the background. Tbh, they only look cool. Functionally same old inputbox.

We need a cool inbox. Functionally and graphically somewhat advanced than the others. What do we mean by functionally advanced? The default InputBox does not perform any validations. Any user entry is returned as string. Which means, you have to let the user enter the incorrect [type of] value before checking whether the value is allowed or not. This was default in 19xx but we are in 2018. User should only be allowed to enter correct types of values. i.e. only be able to enter numbers when asked for numbers, or only valid emails when asked for emails and so on.

Here is a screenshot which asks for a text. (multi line)


When a multiline inputbox is requested, the size of the input box automatically increases.


obviously we should be able to change the theme colour. like below. Only a valid date can be entered. if Email is requested, a valid email is required before closing. etc. etc.

Modern Inputbox for vba purple


if password is requested, a masked field is shown, if shortdate is requested,

Modern Input box for VBA


Check my GitHub and download the sample ACCDB or EXCEL and see how you can copy this function to your project.

If you already have the vba_tools.dll linked in your project. below code will make it work for you.

Private Sub Command78_Click()
‘    Public Enum InputBoxType
‘    {
‘        Password        = 1,
‘        Text            = 2,
‘        MultilineText   = 32,
‘        Number          = 4,
‘        ShortDate       = 8,
‘        LongDate        = 16,
‘        DateTime        = 48,
‘        Email           = 96,

‘    }
    gDll.Toast "you’ve entered: " & gDll.DLL.showinputbox(Type:=2, Title:="", Message:="You can change my text and colour", ThemeBg:="#aa66cc", ThemeForeColour:="")
End Sub

or simply

result = gDll.DLL.showinputbox(Type:=2)

As mentioned, check out my GitHub and share your thoughts in the comment box.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: