- Open your Visual Basic 2008
- Go to File Menu, Select New Project and choose "Windows Form Application" as shown in Figure 1.a and Select "OK" button.
Figure 1.a
3. In the left side of code editor, there's a sidebar window of components, under common controls, select and drag the Button to the window form1 and repeat the same way to add two buttons.
4. Click Button1, in the right side of the code editor, the property of each component.
4.a To change the Button1 text, scroll down to locate the property name "Text" by defualt the text name is "Button1" click and change it to "Hit Me".
5. Click Button2, and proceed to 4.a and Button text change to "Close"
6. We are going now to put the code of Button1, double click the Button1 and following code.
MsgBox("Welcome to Visual Basic 2008", MsgBoxStyle.Information, "Welcome")
7. Double click the Button2 and add the following code.
Close()
Code Overview should be like this:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles v Button1.Click
MsgBox("Welcome to Visual Basic 2008", MsgBoxStyle.Information, "Welcome")
End Sub
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles v Button1.Click
MsgBox("Welcome to Visual Basic 2008", MsgBoxStyle.Information, "Welcome")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End Class
End Class
Close()
End Sub
8. To change the Window title "Form1" to "Welcome to Visual Basic 2008"
8.a Click the form, make sure you don't hit any component at the form, go to component area at the right side then select text and change it to "Welcome to Visual Basic 2008"
9. Saving your work, select "File" menu and locate "Save all", Save Project Window will appear, in Name area put the filename of your project "Welcome", select your folder location in your drive and solution given automatically but you can change it if you want.
10. How to run your first Visual Basic .Net 2008 Project
10.a There are many ways to run your VB application
1. Press F5 - shortest way
2. Click the green arrow right
3. Go to "Debug" menu and select "Start Debugging"
11. OK, if you see the window name "Welcome to Visual Basic .Net 2008", then it's working, if not better review the code.
12. Try to click the button "Hit Me",
13. Try to click the "Close" button, if the close and return to Visual Code editor, well done!
0 comments:
Post a Comment