So example i have Box1, Box2, ..., Box5. All are Textboxes
Its in row for serial key, if you dont understand i can make screen.
Is there anyway i could Copy/Paste all data from all boxes in format like Box1 - Box2 - Box3 etc? and in same way paste it in textboxes?

Recommended Answers

All 7 Replies

Not really sure about the best way to capture the key input but I would think this would put the data to the clipboard (haven't tested it)

            str1 = TextBox1.Text
            str2 = TextBox2.Text
            str3 = TextBox3.Text
            mstr = str1 + "," + str2 + "," + str3
            Clipboard.SetData(mstr, Text)

It should work, but is there anyway I could make if user copy first textbox to it automatically copy all other and same with paste?

You'd need to show me what you have done already, specifically how are you handling the user wanting to copy the textbox?

If you want to make it dynamic then you can do it as follows. For this example create a form with four textboxes. TextBox4 will get the strings from the other three dynamically as you type.

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load

        AddHandler TextBox1.TextChanged, AddressOf TextChange
        AddHandler TextBox2.TextChanged, AddressOf TextChange
        AddHandler TextBox3.TextChanged, AddressOf TextChange

    End Sub

    Private Sub TextChange(sender As Object, e As EventArgs)

        TextBox4.Text = TextBox1.Text & " - " &
                        TextBox2.Text & " - " &
    End Sub

End Class

Jims reply is probably the better solution, but if you're copying them from one text box to another on the same form then surely just

textbox5.text = textbox1.text

you might have to invalidate the control (i.e textbox5 ... textbox8) <- that might be making it more complicated than it needs to be though.

I understand that you want to make the program such that if user hit "Ctrl + C" Key on textbox1, then it must be copy as: Textbox1-Textbox2-Textbox3-Textbox4-Textbox5 ? Am I right?
Then you can do simple thing. you can create shortcut fuction (i mean change it)

And then code is simpler:
box1 = textbox1.text
box2 = textbox2.text
box3 = textbox3.text
box4 = textbox4.text
box5 = textbox5.text
String = box1 & "-" & box2 & "-" & box3 & "-" & box4 & "-" & box5
clipboard.text = String

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.