Results 1 to 4 of 4

Thread: easy beginer question for the pros...

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2000
    Posts
    537
    I hope I can make this make sense....
    I have two buttons named cmdButtonOne and cmdButtonTwo and two text fields named txtOne and txtTwo, and one text field named txtInput.
    what I want is the user inputs text into txtInput and when they click one of the buttons it puts the text into the apropriate txtfield(txtOne or txtTwo depending on what button they click)
    here is the code I have at the moment(I have tried everything possible tonight)
    Private Sub cmdOne_Click()

    Static strInput As String
    'set property of txtOne to strMain

    strInput = txtMain.Text

    If strInput = "" Then
    txtOne.Text = txtInput.Text
    Else
    txtOne.Text = strInput
    End If
    'clear txtInput
    txtInput.Text = ""
    End Sub

    I tried to dim the strInput in (general)but I couldn't get it to work...I can get this to work by not using the dim or static variable it is not as efficiant.
    I hope this made sense.
    Thanks to anyone who helps out.
    Pnj
    pnj

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    How about:
    Code:
    Private Sub cmdButtonOne_Click()
        txtOne.Text=txtInput.Text
    End Sub
    
    Private Sub cmdButtonTwo_Click()
        txtTwo.Text=txtInput.Text
    end Sub
    That would put the txtInput into appropriate textbox (textone or texttwo) depending on what button the user pressed

  3. #3
    Guest
    Just a note. Because the Text of a TextBox is the default property, you can omit the .Text when you are working with it.

    Code:
    txtOne = txtInput

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2000
    Posts
    537

    Thanks..but......uh.......:)

    Thanks Megatron and QWERTY, but I was trying to create a variable and check the txtinput box then use the variable if txtInput was empty.
    I figured it out though.
    by the way I got this to work (the actuall project has four buttons and 5 text boxs. the idea is text is only in one box at a time and moves to what ever button the user clicks on)
    but the code I use was WAY to long somthing like
    if txtOne="" AND txtTwo ="" and ect....
    checking all the boxes. I had five If then else statments for each button.
    anyways.............
    thanks for the response.I'm sure I'll be back with more questions.
    pnj



    pnj

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