|
-
Jul 26th, 2000, 12:49 PM
#1
Thread Starter
Member
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!
Jerome W. Norgren
"Know how to ask. There is nothing more difficult for some people, nor for others, easier."
- Baltasar Gracian
-
Jul 26th, 2000, 01:11 PM
#2
_______
<?>
Code:
Private Sub cmdAdd_Click() ' OK Button.
if textname.text = "" then
msgbox "Sorry, No Data"
textname.setfocus
exit sub
end if
Form2.lstClient.AddItem txtName.Text ' Add to List.
txtName.Text = "" ' Clear text box.
txtName.SetFocus
'Hide and Unload the Dialogbox
Dialog3.Hide
Unload Dialog3
'bla bla
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jul 27th, 2000, 12:42 AM
#3
Thread Starter
Member
HeSaidJoe,
Thanks, with a few minor changes it works like a charm!
I like the message box idea better than just closing the dialog box, which is what I had been thinking of.
If I knew how to give you three thumbs up with the icons for that one I would!
Thanks again!
Jerome W. Norgren
"Know how to ask. There is nothing more difficult for some people, nor for others, easier."
- Baltasar Gracian
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|