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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

press "Enter" in numeric Textbox alters the value of the textbox 2

Status
Not open for further replies.

Harry_Clipper

Programmer
Dec 2, 2020
12
DE
(At first: Sorry for my english)

Hello All,

I have a problem with numeric textboxes.

(I have to reprogramm a whole VB6 Programm (>250K lines) in VFP 9. I wrote an Converter for this and it worked really good)

So, now my Problem:

On a form there are 27 textboxes with numeric values in it and some of it have to Change on some of the Digits.
for example:
4788.35 is the Initial value
I want to Change the 2nd digit :
4888.35
So, I select the "7" overtype it with "8" and press ENTER. (the TextBox shows 4888.35 till I press ENTER)
then the TextBox.value changed to 48.00

When I do the same with TAB all ist fine. BUT I must use ENTER or I have to Change it in the whole Programm.

This happens even when it is an "normal" numeric TextBox with no controlsource, etc.
It does not happen when the TextBox has a Character value, but I must have it numeric....

Did someone knows a Workaround or can otherwise help me?

thnx

Harald
 
The Keypress could select all when ENTER is pressed:

Code:
LPARAMETERS nKeyCode, nShiftAltCtrl
      
IF nKeyCode = 13 AND nShiftAltCtrl = 0
   This.SelStart = 0
   This.SelLength = LEN(This.Text)
ENDIF

You better make this in a textbox class and only use it for numeric input. It may not work for a general-purpose textbox base class, though I don't see a case where it would hurt to select all text, because after the focus changed, the selection will go away anyway.

Chriss
 
Dear Chris,

this really works great!

Thank you so much.

Harald
 
or in Keypress:

Code:
LPARAMETERS nKeyCode, nShiftAltCtrl	

if nkeycode=13
        nodefault
	thisform.text2.setfocus  && or whatever
endif

But of course, no class
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top