Sticking ":" Between Two Numbers Automatically On KeyDown Event

Hi,

I am trying to make formatting times in my app easier for the user. The times are formatted like 12:45. I want to put the colon in automatically so all the user would have to do is type… 1245 and they would get 12:45.

The code is in the Keydown event. The code I was using on the Mac is as follows:

[code] If me.text.Len = 2 then

me.text=me.text+ ":"

end if[/code]

This works great on the Mac and does what I want it to do. But when I run the same code in Windows I get 1245:

The colon is put in back of all four numbers instead of in the middle. Does anyone know what may be causing this not to work under Windows, but work correctly on the Mac?

Any help would be greatly appreciated.

Thank you.

James

[quote=169101:@James Redway]Hi,

I am trying to make formatting times in my app easier for the user. The times are formatted like 12:45. I want to put the colon in automatically so all the user would have to do is type… 1245 and they would get 12:45.

The code is in the Keydown event. The code I was using on the Mac is as follows:

[code] If me.text.Len = 2 then

me.text=me.text+ ":"

end if[/code]

This works great on the Mac and does what I want it to do. But when I run the same code in Windows I get 1245:

The colon is put in back of all four numbers instead of in the middle. Does anyone know what may be causing this not to work under Windows, but work correctly on the Mac?

Any help would be greatly appreciated.

Thank you.

James[/quote]

Put a mask of

##\\:##

in the properties of a textfield for entry.

Thanks so much Michel. I really appreciate your help. Thanks so much for taking the time to help me.