Consulting

Results 1 to 2 of 2

Thread: Text Box formatting.

  1. #1
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location

    Text Box formatting.

    I have an activeX text box that I need to mask for phone number after entry. Hopefully like this (999)999-9999. I dont see a clear way to do it in the text box properties. Any ideas appreciated in advance.

    Also, how do you do tab order for text boxes, not in a form?
    Peace of mind is found in some of the strangest places.

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    A class method might be needed if you have many of those. Otherwise:
    Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If vbTab = Chr(KeyCode) Then TextBox2.Activate
    End Sub
    
    
    Private Sub TextBox2_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
     If vbTab = Chr(KeyCode) Then TextBox3.Activate
    End Sub
    
    
    Private Sub TextBox3_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
     If vbTab = Chr(KeyCode) Then TextBox1.Activate
    End Sub
    
    
    Private Sub TextBox1_LostFocus()
      TextBox1.Value = Format(TextBox1.Value, "(000)000-0000")
    End Sub
    
    
    Private Sub TextBox2_LostFocus()
      TextBox2.Value = Format(TextBox2.Value, "(000)000-0000")
    End Sub
    
    
    Private Sub TextBox3_LostFocus()
      TextBox3.Value = Format(TextBox3.Value, "(000)000-0000")
    End Sub

Posting Permissions

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