Results 1 to 4 of 4

Thread: [RESOLVED] Interchangeable textboxes

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2011
    Posts
    29

    [RESOLVED] Interchangeable textboxes

    I basically want to know if there is a way to make it so that if I write something in "text1" then it will also put that into "text12" and vice versa
    I was trying to do this with a timer set to 15ms and this was my code

    [code]
    Private Sub Timer1_Timer()
    Text1.Text = Text12.Text
    End Sub[code]

    That codes puts what I put in textbox12 also into textbox1, which is what I want, BUT when I try and put something in textbox1, it erases it.. So... Help?
    Last edited by Dgameman1; Apr 13th, 2011 at 01:11 AM.

  2. #2
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: [HELP] Interchangeable textboxes

    You could try using the KeyPress events and remove the need for a timer
    Code:
    Option Explicit
    
    Private Sub Form_Load()
    Text1.Text = ""
    Text12.Text = ""
    End Sub
    
    Private Sub Text1_KeyPress(KeyAscii As Integer)
    Text12.Text = Text12.Text & Chr(KeyAscii)
    End Sub
    
    Private Sub Text12_KeyPress(KeyAscii As Integer)
    Text1.Text = Text1.Text & Chr(KeyAscii)
    End Sub

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2011
    Posts
    29

    Re: [HELP] Interchangeable textboxes

    Quote Originally Posted by Doogle View Post
    You could try using the KeyPress events and remove the need for a timer
    Code:
    Option Explicit
    
    Private Sub Form_Load()
    Text1.Text = ""
    Text12.Text = ""
    End Sub
    
    Private Sub Text1_KeyPress(KeyAscii As Integer)
    Text12.Text = Text12.Text & Chr(KeyAscii)
    End Sub
    
    Private Sub Text12_KeyPress(KeyAscii As Integer)
    Text1.Text = Text1.Text & Chr(KeyAscii)
    End Sub
    Thank you so much =D

  4. #4
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: [RESOLVED] Interchangeable textboxes

    One thing to note, the solution above will not work if the user copies and pastes some data into one of the textboxes. You may need to play with the 'KeyPress' and 'Change' events if you want to support copy and paste.

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