Visual Basic Lessons
From Wikibooks, the open-content textbooks collection
Contents |
[edit] Lesson 1 - Getting Started
Launch Visual Basic. You should see a window that is probably named Form1. Something like this...
(Image Not Found)
You can rename this later. Make sure you have a toolbox and a properties window. If not, click on view and then click on whichever box you need. Now we are going to create a text editor. It is a fairly simple program to create. Now make a textbox by selecting it from the toolbar. Once you have a textbox, you should should change some of its properties. "exe. Multiline I True " Now you have made a simple text editor. Save your progress and move on to Class 2.
[edit] Lesson 2 - Simple Codes
Now that you have a program, it needs code. To give you an idea, select command button on the toolbox. Double click to insert code. Here is an example of a simple code...
Private Sub Command1_Click() 'use a single quote to make a comment on your code. 'this code ends the program End End Sub
Now that was pretty easy right? Good so now you are ready for step 2, using code to change your project while running...
Private Sub Command2_Click() 'Let's make Text1 say "Hello World!". First, tell the computer what object you want to change. akaText1 Text1 'Now we need to tell it what property to change Text1.Text 'Finally, we tell it what to change it to Text1.Text = "Hello World" End Sub 'Got it? That was a lot to take in at once. You are now ready for Class 3.
[edit] Lesson 3 - The If Statement
Private Sub Command3_Click() 'This lesson is all about the "If Statement". 'Lets make it so when we click command 2, the program ends but if not we hear that really annoying beeping noise. If Text1.Text = "Hello World" Then 'We end the program End 'But if it doesn't, it should beep so... Else Beep 'Pretty easy to understand right? End Sub 'OK, now you are ready for Class 4
[edit] Lesson 4 - The Menu
You know that menu thing on the top of the page? Well that's what I'm going to tell you how to do this time. If you haven't already, open your project. Click on the little button under the menu that looks like a menu. If you're not sure, then put your mouse over it until it says something like Menu Edit. The screen that pops up is fairly simple and you should be able to figure it out. Now you can create various objects like commands that when clicked read your code. Now you are ready to save the text you write with the code written in the next class. Good luck and goodbye for now.
[edit] More Lessons @
For More Free VB Stuff Go To...