Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Back space key goes to another Text box

Status
Not open for further replies.

VictorFRodriguez

Programmer
Jan 20, 2001
51
0
0
DO
I have a form with several text boxes. When I type something wrong and push the back space to the beggining, sometimes goes to a previous box.
Is there any trick that allows the cursor to STOP when is at the first position?
Victor F. Rodrigueez
 
VictorFRodriguez

This has been brought up a few weeks back, a partial solution is in the Keypress Event of the form, make sure the Keypreview of the form is set to .T.. Copy the following into a program and run it. (BTW you can alos add code for all the controls on your form.):
Code:
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN
DEFINE CLASS form1 AS form
	DoCreate = .T.
	Caption = "Form1"
	KeyPreview = .T.
	Name = "Form1"
	ADD OBJECT text1 AS textbox WITH ;
		Height = 23, ;
		Left = 60, ;
		Top = 36, ;
		Width = 100, ;
		Name = "Text1"
	ADD OBJECT text2 AS textbox WITH ;
		Height = 23, ;
		Left = 144, ;
		Top = 132, ;
		Width = 100, ;
		Name = "Text2"
	PROCEDURE KeyPress
		Lparameters nKeyCode, nShiftAltCtrl
		If nKeyCode = 127
			Thisform.SetAll("Tabstop",.F.,"textbox")
		Else
			Thisform.SetAll("Tabstop",.t.,"textbox")
		Endif
	ENDPROC
ENDDEFINE


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Also, you can include this code to your textbox VALID clause:


IF EMPTY(THIS.value) AND LASTKEY() = 127
RETURN 0
ENDIF




Gerardo Czajkowski
ltc.jpg
 
Use "SET CONFIRM ON" - Specifies that the user cannot exit a text box by typing past the last character in the text box.
I hope this help you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top