Overclock.net banner

1 - 5 of 5 Posts

·
Registered
Joined
·
24 Posts
Discussion Starter · #1 ·
Hi, I've just made a simple auto typer and it has buttons which you can press that insert text in the text box. But at the moment it will only let one piece of text be inserted into the box, i want it so i can press two button and both of there text will appear, sorry for my bad explanation, thanks


Here is the code from one of the buttons:

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox1.Text = ("red:")

End Sub
 

·
Premium Member
Joined
·
1,592 Posts
Quote:


Originally Posted by DreadedJoe
View Post

Hi, I've just made a simple auto typer and it has buttons which you can press that insert text in the text box. But at the moment it will only let one piece of text be inserted into the box, i want it so i can press two button and both of there text will appear, sorry for my bad explanation, thanks


Here is the code from one of the buttons:

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox1.Text = ("red:")

End Sub

You want to concatenate the strings. I forget what the VB syntax is but it would be something along the lines of TextBox1.Text = TextBox1.Text + ("red:")

EDIT: Try String.Concat(TextBox1.Text, str)

Where str is the text you want to add to the box.
 

·
Registered
Joined
·
74 Posts
Quote:


Originally Posted by mott555
View Post

For VB .NET you can use + or & to perform string concatenation.

In .NET strings are immutable which means that any changes to a string (by & or +) causes the runtime to create a new string and discard the old one. These old strings are then handled during garbage collection.

This can and should be avoided by simply using the format, join or concat methods of the string object or altenatively use the StringBuilder class to create dynamic (mutable) strings.

The latter is my preferred way as it spans multiple statements and can grow as needed from it's initial 16-byte buffer that is allocated by the default constructor.
 
1 - 5 of 5 Posts
Top