Results 1 to 8 of 8

Thread: changing masked edit from one form to another

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Location
    Calgary,Alberta, Canada
    Posts
    70

    Post

    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

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

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

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Location
    Calgary,Alberta, Canada
    Posts
    70

    Post

    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

  4. #4
    Member
    Join Date
    Nov 1999
    Location
    Dover, NH
    Posts
    54

    Post

    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.

  5. #5
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    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.


  6. #6

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Location
    Calgary,Alberta, Canada
    Posts
    70

    Post

    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

  7. #7
    Member
    Join Date
    Nov 1999
    Location
    Dover, NH
    Posts
    54

    Post

    Just curious. Did it work?

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Location
    Calgary,Alberta, Canada
    Posts
    70

    Post

    thxs tpatten worked like a charm so did pool
    one more match to win and off to the canadians

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width