masked edit

how to use masked edit
input control using #### for a 4 digit number
how can I do it?
please an example

a = InputBox("typ uw geboortejaar", "jaar", "19..", 3000, 3000)
maskeditbox1.mask = "####"
but the thing above does not work
a must be a year if else it must generate an error

thanks in advance,
please mail me direct:

If you enjoyed this post, subscribe for updates (it's free)

How to use VB6 Masked Text Box

To put a masked text box in your VB app do the following:
  • In the menu bar at the top of the VB6 IDE select Project -> Components.
  • In the pop up that appears scroll down until you see the Microsoft Masked Edit Control 6.0
  • Check the box next to this item
  • Click Ok in the dialog
  • Notice in the toolbox (on the left side of the screen) you have a new control that looks like this: ##|
  • Drag that control onto your form.
Now you can make use of the VB6 MaskedTextBox however you want. Please see the post below for an example of how it can be used.


I know this is an old topic but no one has answered it.

You can set your Mask at DesignTime or RunTime.

Private Sub Form_Load()
MaskEdBox1.Mask = "####"
End Sub
Now your problem is using the InputBox info in the MaskEdBox1.
Private Sub Command1_Click()
Dim A As Integer
A = InputBox("typ uw geboortejaar", "jaar", "19..", 3000, 3000)
MaskEdBox1.Text = A
End Sub

But you would have to check for the length of A because the Mask is 4 characters.


I've been programming with VB for 12 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning