Auto populate fields

I have 2 text fields and I want one to detect when there is a number in the field and then have that number auto populate into the second text field.

in the textchanged event…


try
if  isnumeric( me.text) then otherfield.text = me.text
catch
end try

Noah, one way to do this is with the TextChanged event. Drag a TextField on to the window. Name it TextField1. Drag another TextField on to the Window. Name it TextField2. Right click on TextField1 and select Add To “TextField1” Event Handler. Then select the event TextChanged. In that event, put the code:

TextField2.Text = me.Text

I left out the part about determining the number, but @Jeff_Tullin showed you.

Alright I understand that part!

I don’t get that part

i got

Is there a reason why you did not use this?

happenedFeil and oldFeild are the to fields im using here

Yes, BUT you didn’t include .text, and you dint use isnumeric
me.text in the textchanged event of happenedFeil would be the same as
happenedFeil.text

I got it working but I also want to be able to put other letters in the field and only the number in the second field

Yeah, sorry i fixed that but

New information.
Now you mean ‘if there are any numbers’
Some people would advise using Regex. It wont help you.

Consider these:

A123 - you want 123?

A12B34 - do you want 1234?

1234E5 - this is a big number if treated as scientific notation … 123400000

You could extract all numbers using a loop: something like this…


var nums as string
for x as integer = 1 to me.text.length
   //if  the nth character is a number, add it to the string  nums
next

if nums > "" then oldfield.text = nums

Why would you assume that a number in the ‘tell me’ box is an age?

‘Tell me exactly what happened?’ "Well, I bought 6 eggs to make an omelette…’

I suspect

Are you with the patient now? can be a checkbox… it’s faster than a dropdown.

and ‘concsious’ should be ‘conscious’
:slight_smile:

Oldfield … you spelled that as Oldfeild

I ran out of replies

noahr48@educbe.ca

email me

The last code I gave you is not complete. I left some of it for you to write.