-
On one form I have a mask edit control mskphone (###)-###-#### when loading the second form I want to load the numbers into a textbox but without the hypens or Brackets
eg mskPhone = Form2.txtTextbox
(555)-555-5555= 555555555
any ideas i have tried several ways but once again i am need of some help
thxs in advance :)
-
Maybe this will help (I'm sure that there is easier way but I can't think about it right now)
Module code
Code:
Function TrimSpaces(Text As String)
Dim trimspace As Integer
Dim thechar$, thechars$
If InStr(Text, " ") = 0 Then
TrimSpaces = Text
Exit Function
End If
For trimspace = 1 To Len(Text)
thechar$ = Mid(Text, trimspace, 1)
thechars$ = thechars$ & thechar$
If thechar$ = " " Then
thechars$ = Mid(thechars$, 1, Len(thechars$) - 1)
End If
Next trimspace
TrimSpaces = thechars$
End Function
Form2_Load Event code
Code:
Private Sub Form_Load()
Dim I As Integer
Dim aString As String
Text1.Text = Form1.mskPhone.Text
For I = 1 To Len(Text1.Text)
If Mid(Text1.Text, I, 1) = "-" Or Mid(Text1.Text, I, 1) = "(" _
Or Mid(Text1.Text, I, 1) = ")" Then
aString = Text1.Text
Mid(aString, I, 1) = " "
Text1.Text = aString
End If
Next I
Text1.Text = TrimSpaces(Text1.Text)
End Sub
[This message has been edited by QWERTY (edited 11-30-1999).]
-
thxs qwerty i didn't think it would be that complicated i save your code for future reference it'll help me in the future
-
Have you tried the cliptext property? For example:
PhoneNum = mskPhone.ClipText
This should only give you the numbers that were entered and not the literals.
-
Told you there is an easier way
------------------
Visual Basic Programmer (at least I want to be one)
------------------
PolComSoft
You will hear a lot about it.
-
Well look at the Bright side Qwerty least i learned about the Trim function don't have time tonight to try your way tpatten but thxs for your reply Have Pool tonight IF we win
it could mean a trip to the Canadian championships in January :)
-
Just curious. Did it work?
-
thxs tpatten worked like a charm so did pool
one more match to win and off to the canadians :) :)