conditional formatting

ssh

Registered User.
Local time
Today, 11:34
Joined
May 22, 2002
Messages
49
How to format data depending on value's lenght. Example, format a 8-characters value 12345678 to (123) 45 678.
 
You may want to experiment with Left, Right and Mid functions. For the moment, here's a prosaic, late night, brutish approach:

Assume there's a a command button and a text box named TxtTest on your practice form. Assume there's an 8-character string --- 12345678 -- in TxtTest.

Private Sub CmdTest_Click()

Dim TxtTmp As String

If Len(Me.TxtTest) = 8 Then
TxtTmp = "(" & Left(Me.TxtTest, 3) & ")" & " " _
& Mid(Me.TxtTest, 4, 2) & " " _
& Right(Me.TxtTest, 3)
Me.TxtTest = TxtTmp
End If

End Sub

Regards,
Tim
 
Worked, thank you Tim!
 

Users who are viewing this thread

Back
Top Bottom