I have the following code (mouse down) to select/highlight the entire contents of a textbox in a userform. I have this code to prevent the user from clicking in the middle of a formatted number and only changing certain digits (I want them to change the entire number). It works about 98% of the time, but sometimes I can still click on the very beginning of a formatted number ($45,000 for example) and enter a number BEFORE the $. I NEVER want the user to be able to do this.
1. Is there something about a FORMATTED number that allows me/user to enter a number in front of the $?
2. Does it have something to do with weird stuff that can occur in a textbox? My textboxes are NOT located in frames, but they are in labels.
3. Is there a way to alter the code to prevent this? Should I put in a Before Update event to recheck the number (i already have key press events to ensure a number is entered).
1. Is there something about a FORMATTED number that allows me/user to enter a number in front of the $?
2. Does it have something to do with weird stuff that can occur in a textbox? My textboxes are NOT located in frames, but they are in labels.
3. Is there a way to alter the code to prevent this? Should I put in a Before Update event to recheck the number (i already have key press events to ensure a number is entered).
Code:
Private Sub TextBox137_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
TextBox137.SelStart = 0
TextBox137.SelLength = Len(TextBox137.Text)
End Sub