PDA

Click to See Complete Forum and Search --> : changing masked edit from one form to another


Jessie
Nov 29th, 1999, 07:29 AM
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 :)

QWERTY
Nov 29th, 1999, 10:55 AM
Maybe this will help (I'm sure that there is easier way but I can't think about it right now)

Module 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

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).]

Jessie
Nov 29th, 1999, 11:01 AM
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

tpatten
Nov 29th, 1999, 08:53 PM
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.

QWERTY
Nov 30th, 1999, 01:42 AM
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.

Jessie
Nov 30th, 1999, 07:28 AM
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 :)

tpatten
Dec 1st, 1999, 08:51 PM
Just curious. Did it work?

Jessie
Dec 3rd, 1999, 03:41 AM
thxs tpatten worked like a charm so did pool
one more match to win and off to the canadians :) :)