|
-
Nov 29th, 1999, 08:29 AM
#1
Thread Starter
Lively Member
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
-
Nov 29th, 1999, 11:55 AM
#2
Fanatic Member
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).]
-
Nov 29th, 1999, 12:01 PM
#3
Thread Starter
Lively Member
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
-
Nov 29th, 1999, 09:53 PM
#4
Member
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.
-
Nov 30th, 1999, 02:42 AM
#5
Fanatic Member
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.
-
Nov 30th, 1999, 08:28 AM
#6
Thread Starter
Lively Member
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
-
Dec 1st, 1999, 09:51 PM
#7
Member
Just curious. Did it work?
-
Dec 3rd, 1999, 04:41 AM
#8
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|