Hello,
I've a problem that I'm not sure how to solve, ie... A dialogbox that Inputs textnames into a listbox, the problem is that if I click on the "OK" button before inputing any text I get a blank line in the listbox. Which I don't want to happen, here's the code I'm using for the textbox and the "OK" button any suggestions on what's wrong? Oh, yes! I should mention that the listbox is check box style.
Private Sub cmdAdd_Click() ' OK Button.
Form2.lstClient.AddItem txtName.Text ' Add to List.
txtName.Text = "" ' Clear text box.
txtName.SetFocus
'Hide and Unload the Dialogbox
Dialog3.Hide
Unload Dialog3
End Sub
Private Sub txtName_KeyPress(KeyAscii As Integer)
' Enable the Add button if there is at least one
' character in the name.
cmdAdd.Enabled = (Len(txtName.Text) > 0)
' If Enter is pressed nullify the keystroke
' and Tab to the OK button and press enter
If KeyAscii = 13 Then
KeyAscii = 0
SendKeys "{TAB}{ENTER}"
End If
End Sub
Thanks in advance!




Reply With Quote