Re: Problem with Enter Key
Hi,
The support by VB for the enter key is limited because this key and the tab key) has a special meaning to Windows.
For yr password: the textbox.maxlength can be set to the required length of the password.
Then:
Sub text1_change()
If Len(text1.text) = Text1.MaxLength Then
SendKeys "{Tab}"
End If
End Sub
The code will then send a tab command. If you set the Taborder of the OK command to +1 compared to that of the txtPassword box, then the OK command will be automatically addressed.
I hope I'm right. Try something like this
Jan
Re: Problem with Enter Key
User can enter max. of 10 letters in Password field. But happens if he/she enters less than 10 characters and press enter key.
chakradhar
Software Engineer
IT Solutions India
Banagalore
Re: Problem with Enter Key
can you give some more information on how your passing the user name and password?
I think that the problem occurs in that part, because if you look in debug mode to the fields, the string you put in is correct (without any extra characters)
Re: Problem with Enter Key
Try catch the enter key by trapping keyboard activity:
private Sub Text1.KeyPress(KeayAscii as Integer)
Select Case KeyASCii
Case is 13 'I suppose 13 is the enter key
KeyAscii = 0 'zero
Case Else
'no code
End Select
Remark: check in an ANSI code list.
Further: The keypress event can trap the enter key in the textbox only if there's no command button control on the form whose default property is set to true. If the form has a default push button, the effect of processing the enter key is clicking on that button. So set the default property to false.
Similarly no Escape key goes through this event if there's a Cancel button on the form.
Jan