OSIRIS Grandmaster Cheater Reputation: 0
Joined: 27 Aug 2006 Posts: 654
|
Posted: Sun Mar 09, 2008 8:15 pm Post subject: [PICTURE TUTORIAL] VB2008 - Properties |
|
|
To make your first form
This is fairly easy. File>New Project Now name it and hit OK
Properties
Every single thing in Visual Basic has properties. There are 2 ways of editing properties.
1) Desinger
2) Code
1- Designer
This is really easy. For example modify the text area to Hello. Then form1 will now be titled Hello. Play around with these as you should know some of them before continuing.
2- Code
This is were you would modify the code of the the app to modify properties. For an example form1 is the name is the main window. If you would want to change it to hello using code you use this.
Your first application.
So now if you where playing around with any thing create a new project. Now place a button and a label there.Resize the corners to make it look good It should look something like this.
Double click on the button to go its code. There should be something looking like this.
Code: |
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
|
What our goal is, when you hit button1 the label will change to Hello. So remember how everything has a property. So do labels. So when we hit button1 we want this to happen.
Code: |
label1.text=("Hello")
|
So now put that inside the code that was already there and you get.
Code: |
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
label1.text=("Hello")
End Sub
|
Run your program by pushing F5 and click the button. The label should now change to Hello.
More advanced
Now keep everything the same way it is. Except add a text box onto the form. It should now look like this.
Now our goal is to. When button1 is pressed the text that is inside textbox1 will be displayed into label1. So basically where taking textbox1.text and puttting it to label1.text. So now modify your code to look like this.
Code: |
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
label1.text=textbox1.text
End Sub
|
Run it, so now what ever is in the textbox goes to the label.
You just got to remember that everything has a property, the most comonly used one is text. Just enter the object names then .text. Example.
combobox1.text
label2.text
webbrowser1.text
listbox1.text
There are also properties such as BackColor this is the background color of the object. So now make a new button. And in the code enter this.
Code: |
Me.BackColor = Color.Aquamarine
|
You can't use
Form1.BackColor = Color.Aquamarine
becuase form1 cant refer to its self so instead we would use Me.
So this concludes my quick tutorial. There are so many properties out there for you explore are get experinced with.
|
|