Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Concatenation

jjdickowjjdickow Posts: 1Member
[link=http://vb-board.com]Concatenation [/link]is pretty much the addition of strings. This is frequently used in many programs and also a very simple concept.

Here is an example:
1. Open a new project
2. Add one button and two textboxes
3. Double click your button and add this code:
[code] Dim strOne As String
Dim strTwo As String
strOne = TextBox1.Text
strTwo = TextBox2.Text

MessageBox.Show(strOne & " " & strTwo)[/code]

Explanation:
-If you didn't know dim is the same thing as "define" it defines your variables. We defined two different strings here (strOne and strTwo).
-We then set each string equal to a textbox. It is set to textbox1/2.TEXT because you are setting it equal to what was entered into the textbox.
-After defining variables we use messagebox.show (pretty much a pop up which you can add extra functions but I will not use those) and we are making it show strOne, a space, and strTwo.
-Notice we use the ampersand (&). This is what you use to connect any variable with anything in quotes. We connect what ever strOne is equal to, a space (between quotes is the space), and what ever strTwo is equal to.
-Run your application (F5) and enter "Hello" in the first textbox and "Bob" in the second. click your button and a messagebox should pop up saying "Hello Bob"


Mess around with random uses like this until you get the hang of it. Then keep moving forward in your Visual Basic Career :P

Sign In or Register to comment.