Verifying that data exist
Add code to UserForm_Initialize() event
Private Sub UserForm_Initialize()
ComboBox1.AddItem "1"
ComboBox2.AddItem "2"
'same for adding 3 to 8
End Sub
Combo box can only display 1 row while listbox can display several rows
Also combo box allows user to type in other values if style is set to 0
- frmStyleDropDownCombo
WLMPilot wrote:
I thought a combobox would be better. I am new to VBA. What would the code
be to completely create the combobox with only 1-8 as a choice?
Also, what is the difference between a listbox and combobox?
Thanks,
Les
"equiangular" wrote:
1. In order to stay the focus, you hv to use Cancel=True instead of
txtST.SetFocus
2. If you only allow the user to enter 1-8, I think it's better to use a
combobox instead and add the code to UserForm_Initialize() like this
Private Sub UserForm_Initialize()
ComboBox1.AddItem "1"
'.....
End Sub
WLMPilot wrote:
I wanted to create a routine to make sure the user not only entered something
in the textbox of the userform, but that the answer is a valid answer. The
routine below is for checking to be sure something was entered. However, it
does not seem to work. Any suggestions?
Private Sub txtST_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If txtST = "" Then
txtST.SetFocus
End If
End Sub
Now for the second part. The field, txtST, will contain a value from 1 to
8. I would actually like to have a listbox for this field so the user can
choose and I do not have to verify if input is correct. How do I do this?
Thanks,
Les
|