|
-
Feb 2nd, 2000, 10:28 PM
#1
Thread Starter
Lively Member
OK if i want to format a textbox so 'currency' or 'date' or something else where is it best to do it, such as under txt_GotFocus or txt_Change or something else so that it stays that when it is changed and saved like that?? PS Could you throw in the format for PhoneNumber?
-
Feb 2nd, 2000, 11:57 PM
#2
Frenzied Member
I reckon either in LostFocus or trapping a return key press would be as good a place as any!
eg:
Code:
Private Sub text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
text1.Text = format(...... text1.Text etc)
End If
End Sub
------------------
Mark Sreeves
Analyst Programmer
[email protected]
A BMW Group Company
-
Feb 2nd, 2000, 11:59 PM
#3
Frenzied Member
lost focus would probably be better
you could do both though...
------------------
Mark Sreeves
Analyst Programmer
[email protected]
A BMW Group Company
-
Feb 3rd, 2000, 02:21 AM
#4
Thread Starter
Lively Member
Thanks for all the input. I am learning quick by chatting on VB World, I love it.
-
Feb 3rd, 2000, 12:07 PM
#5
Frenzied Member
I use LostFocus to format the text box;
Sub TextBox1_LostFocus
Textbox1.Text=Format(TextBox1.Text,"Currency")
End sub
Note: If it's currency I tend to use the GotFocus event to return it to a double for easy editing;
Sub Textbox1_GotFocus
TextBox1.Text=Cdbl(TextBox1.Text)
End Sub
As for phone numbers, DO NOT attempt to format them - there is no guaranteed formatting for phone numbers. For example, a load of phone numbers in the UK have just changed (this is about the third change we've had in the last few years), so you never can be sure that they will stay the same.
------------------
Mark "Buzby" Beeton
VB Developer
[email protected]
[This message has been edited by Buzby (edited 02-03-2000).]
-
Feb 3rd, 2000, 12:09 PM
#6
Hyperactive Member
The problem with capturing a key press or the changed event is that if you use the standard :
format(string, style)
then it will fill the rest of the text with with the style. I really haven't been able to make it work there. Generally what I'll do is capture the lost focus. I could be wrong about the other, I've just never got it to work right.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|