Link to home
Start Free TrialLog in
Avatar of jppinto
jppintoFlag for Portugal

asked on

Convert string to special format

Hello,

I'm trying to convert the value of a textbox to something like this;

XXX XXX XXX XXXXXX

Where the value of the textbox can be numbers or letters, upper or lower case.

Example:

I enter 7m0343834ewrw and I want the result to be 7M0 343 834 EWRW.

How do I format MyTextBox?

thanks,

jppinto
Avatar of reb73
reb73
Flag of Ireland image

LEFT(MyTextBox.Text, 3) & " " & MID(MyTextBox.Text,4, 3) & " " & MID(MyTextBox.Text,7, 3) & " "  & MID(MyTextBox.Text,10,50)
Avatar of Patrick Matthews
In VB6...


Dim strInput As String

strInput = UCase(Replace(SomeForm.MyTextBox, " ", ""))
strInput = Trim(Left(strInput, 3) & " " & Mid(strInput, 4, 3) & " " & Mid(strInput, 7, 3) & " " & Right(strInput, 4))

MsgBox strInput
Need more coffee :)
Avatar of jppinto

ASKER

Error:

Public Property Left() As Integer' has no parameters and its return type cannot be indexed.

jppinto
ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jppinto

ASKER

Thanks jpaulino. Now it's working!