Results 1 to 5 of 5
03-20-2012, 12:10 PM #1
[TUT#1]Visual Basic - Declaring a variable as a string
For the first example we will declare a string using a message box.
Open Visual Basic and click "new project" then name your project and click "windows form". When the form opens go to the toolbox tab on the left and click "Button".
Now click the form and a button will appear on it, resize your button as you feel needed. I will teach you how to customize buttons and such in later tutorials.
Double click your button and you will get a screen like this.
This is where all of your "coding" will be done.
Under "Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click" write "MessageBox.Show()".
Now under "Public Class Form1" Write "Dim blahblahwhatthefuckever As String = "Omg I just declared a valiable""
Now to explain that, Dim is what you use to declare something. blahblahwhatthefuckever is the variable I am declaring(it can be titled anything you want), and As String means I am declaring it as text(aka a text string). The "Omg I just declared a valiable"" is just what we want our message box to say.
Now go back to your "MessageBox.Show()" and copy and paste your variables name in the () like this.
So what we are saying is that when button1 is clicked we are declaring our variable "blahblahwhatthefuckever" as a text string in a message box.
Now lets test it, click the play button on top like in this picture.
This should be your result when you click Button1.
Congratulations, you have just declared your first variable.
03-20-2012, 12:12 PM #2
Hm, this is simple enough. It's similar to Objective-C, in the way that you declare variables and name them.
03-20-2012, 05:13 PM #3
Yea, it's a very simple beginners tutorial. I will make more soon more difficult then this.
03-20-2012, 07:59 PM #4
How would you code it if you wanted the text to pop up in a box that you can copy and paste from? (Like a custom class creator program of some sort).
03-20-2012, 08:12 PM #5
Without declaring a variable you could just use a button and a text box and double click the button and type this.
TextBox1.Text = "Text goes here"
So now when we click the button that text in quotations will show up in the textbox and your can copy and paste from textboxes.
If you don't want a bunch of buttons and you just want to use a drop down box then you need a text box and a combo box, and to do this you need to use an if statement. I will explain if statements in my next tutorial which I will probably make tomorrow.