Advertisement
2002VB Coding Standards #24142

An Introduction to Visual Basic

This tutorial will give the beginner programmer a useful introduction to the Visual Basic compiler, the Visual Basic language, and step-by-step instructions on how to make their first program. PLEASE RATE AND LEAVE FEEDBACK! THANK YOU!

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
<html>
<head>
<title>Introduction to Visual Basic</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
 if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div align="center"> 
 <p> </p>
 <p><font face="Arial, Helvetica, sans-serif" size="4">This Tutorial is Also 
 Available at My Website:</font></p>
 <p><font face="Arial, Helvetica, sans-serif" size="4"><a href="http://www.geocities.com/campbell_donalde/vb">http://www.geocities.com/campbell_donalde/vb</a></font></p>
 <p><font face="Arial, Helvetica, sans-serif" size="7"><a name="_top"></a>Introduction 
 to Visual Basic</font></p>
 <p><font face="Arial, Helvetica, sans-serif" size="2">-By Donald Evan Campbell</font></p>
 <p> </p>
 <p align="left"><font face="Arial, Helvetica, sans-serif" size="3">Welcome to 
 <i>Introduction to Visual Basic</i>! You may think that Visual Basic is hard, 
 but it is not. It is not easy, either - it is just right. All you will need 
 to know is in this tutorial, and you should find from this tutorial that Visual 
 Basic can be a blast.</font></p>
 <p align="center"><b><font face="Arial, Helvetica, sans-serif" size="3">Table 
 of Contents</font></b></p>
 <p> </p>
 <p><font face="Arial, Helvetica, sans-serif"><a href="#_intro">Introduction 
 to the Visual Basic Language</a></font></p>
 <p><font face="Arial, Helvetica, sans-serif"><a href="#_compiler">The Visual 
 Basic Compiler</a></font></p>
 <p><font face="Arial, Helvetica, sans-serif" size="3"><a href="#_firstprogram">Your 
 First Program</a></font></p>
 <p><font face="Arial, Helvetica, sans-serif" size="3"><a href="#_wheretogo">Where 
 to Go From Here</a></font></p>
 <p> </p>
 <p align="left"><a name="_intro"></a><font face="Arial, Helvetica, sans-serif" size="6">Introduction 
 to the Visual Basic Language</font></p>
 <p align="left"> <font face="Arial, Helvetica, sans-serif" size="3"> Have you 
 ever heard of BASIC? If you have and you are familiar with its syntax, you 
 know the core of Visual Basic already! If you don't well, then, don't worry 
 about it. You do not (necessarily) need to know BASIC before using Visual 
 Basic. </font></p>
 <p align="left"><font face="Arial, Helvetica, sans-serif" size="3">BASIC is 
 a very old language that was used on mainframes in the late 80's and early 
 90's. It is non-graphical. Its programs look like the MSDOS prompt. Visual 
 Basic was developed by Microsoft(c) as a graphical extension on BASIC. See 
 the button and textbox below? These are the sort of things that you can put 
 into your Visual Basic program. Unlike BASIC, Visual Basic programs look like 
 a window - that is they are like the browser with which you are viewing this 
 webpage right now. </font></p>
 <form name="form1" method="post" action="">
 <input type="submit" name="Submit" value="A Command Button">
 <input type="text" name="textfield" value="A Textbox">
 <font size="3"> <font face="Arial, Helvetica, sans-serif"> 
 <input type="checkbox" name="checkbox" value="checkbox">
 A CheckBox</font></font> 
 <input type="radio" name="radiobutton" value="radiobutton">
 <font face="Arial, Helvetica, sans-serif" size="3">A Radio Button 
 <select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
  <option selected>A DropDown Box</option>
  <option>A DropDown Box</option>
  <option>A DropDown Box</option>
 </select>
 </font> 
 </form>
 <p align="left"><font face="Arial, Helvetica, sans-serif" size="3">How does 
 Visual Basic work? Well basically, Visual Basic is <i>Object Oriented</i> 
 (<a href="#_objectoriented">see the Object Oriented section</a>). That each 
 of the command buttons, textboxes, checkboxes, radio buttons, and dropdown 
 boxes are treated as their own separate entities - they are objects. Think 
 of an object - a phone. What are its properties? It is white. It is covered 
 with buttons. It has a small LCD screen with which to tell who is calling. 
 Look at a command button. What are its properties? It is grey. It is rectangular 
 in shape. It says "A Command Button" on it. It can be clicked. They 
 are treated in similar fasions, for they are both objects.</font></p>
 <p align="left"><font face="Arial, Helvetica, sans-serif" size="3">What does 
 Visual Basic code look like? It is quite simple, really. Unlike UNIX languages 
 like C, C++, Perl, and Python, Visual Basic requires NO semicolon, colon, 
 or comma after each line. Each action you tell the computer to do is printed 
 on its own line - that is if you type two instructions on one line, Visual 
 Basic will think those two instructions are one. Look at this simple Visual 
 Basic <i>subroutine</i> and see if you can tell what it does.</font></p>
 <table width="60%" border="0" cellspacing="0" cellpadding="0">
 <tr> 
  <td bgcolor="#666666"> 
  <p><code>Private Sub CommandButton1_Click()</code></p>
  <p><code> Form1.Caption="Hello. How are you?"</code></p>
  <p><code>End Sub</code></p>
  </td>
 </tr>
 </table>
 <p align="left"><font face="Arial, Helvetica, sans-serif" size="3">What does 
 it do? Do you see the text at the top of your browser's window? That is called 
 the <i>caption</i>. Form1 is your VB program's window. Form1 is an object, 
 therefore it has properties. Caption is a property. The "." or period 
 tells the computer that Caption is a property of Form1. If you do not understand 
 the concept of a form, do not worry. It is explained in more detail further 
 on in this tutorial. </font></p>
 <p align="left"><font face="Arial, Helvetica, sans-serif" size="3">When you 
 set the program's window's caption, you are telling VB to print whatever is 
 in quotations in the same place the caption text is located on your browser 
 window. </font></p>
 <p align="left"><font face="Arial, Helvetica, sans-serif" size="3">If you notice, 
 this "Sub" looks interesting. You see CommandButton1, and _Click(). 
 If you have any programming experience, you will know that anything in parentheses 
 "()" are <i>arguments</i> or values that the computer uses to perform 
 a certain task. The _Click tells the computer to perform whatever you tell 
 it when you click on something. The CommandButton1, as discussed above, tells 
 the computer what <i>object</i> the programmer is talking about. So when will 
 this code take place? If you guessed when you click on the object CommandButton1, 
 you are correct! Private and Public Sub's are <i>subroutines</i>. Subroutines 
 simply are little bits of code that are not part of the <i>main</i> routine 
 - the main heart of your program. You must <i>call</i> or activate a subroutine. 
 The Private tells the computer that this code cannot be accessed by any other 
 application. </font></p>
 <p align="left"><font face="Arial, Helvetica, sans-serif" size="3">At this time, 
 you should have an idea about objects, properties, setting properties, and 
 telling the computer when to execute code. What would be the code to set a 
 commandbutton's (named Command1) caption property to <i>Hey. How are ya? Ya 
 wanna go out sometime?</i>? If you guessed <code>Command1.Caption = "Hey. 
 How are ya? Ya wanna go out sometime?" </code>you are correct. Now, where 
 would the caption appear on a command button? Look back to our example of 
 a command button above. The caption is the statement "A Command Button."</font></p>
 <p align="left"><font face="Arial, Helvetica, sans-serif" size="3">Now for the 
 techical stuff. There are <i>variables</i> in programming - this is the same 
 through all languages. Variables can be declared as different types - depending 
 on what types of data they will be holding. Variables that will be holding 
 text are strings. Variables that will be holding integers, are integers. Variables 
 that are holding decimals are long, and variables holding a true or false 
 value are boolean. To declare a variable in visual basic, you can use two 
 different methods. The Dim Statement is the most popular. It looks like this:</font></p>
 <p align="center"><font face="Courier New, Courier, mono" size="3">Dim [variable] 
 as Type</font></p>
 <p align="left"><font face="Arial, Helvetica, sans-serif" size="3">Where variable 
 is the name of your variable (can be up to 255 characters), and type is the 
 type of data the variable will be holding. You can also use the Public or 
 Private statements. Remember: Public can be used throughout your Visual Basic 
 program. Private can only be used in the <i>subroutine</i> within which you 
 declared your variable.</font></p>
 <p align="center"><font face="Courier New, Courier, mono" size="3">Public [variable] 
 as Type</font></p>
 <p align="center"><font face="Courier New, Courier, mono" size="3">Private [variable] 
 as Type</font></p>
 <p align="left"><font face="Arial, Helvetica, sans-serif" size="3">Visual Basic 
 can also handle <i>arrays</i>. Arrays are variables that are chopped into 
 small blocks. Within each block you can hold a distinct value. Once again, to declare an array, you can use Dim, Private, or 
 Public. Arrays are declared with the number of blocks into which they should 
 be chopped in parentheses - that is [variable name]([number of blocks]). How 
 do you use arrays? Lets say you have 10 employees in your department. Each 
 makes a certain amount of money per hour. Instead of declaring 10 variables 
 to keep track of your employee's salaries, you declare an array - called money, 
 that is chopped into ten blocks. In each block, you hold an employee's hourly 
 salary. Look at the below example to see an array declared.</font></p>
 <p align="center"><font face="Courier New, Courier, mono" size="3">Dim Salaries(10)</font></p>
 <p align="center"><font face="Courier New, Courier, mono" size="3">Salaries(0) 
 = 20</font></p>
 <p align="center"><font face="Courier New, Courier, mono" size="3">Salaries(1) 
 = 21</font></p>
 <p align="left"><font face="Arial, Helvetica, sans-serif" size="3">Arrays, by 
 default, start at 0 and goto whatever number you put in the parentheses. This 
 can be changed, though. Let's say that we need an array with blocks labeled 
 2 through 9. You would declare it like:</font></p>
 <p align="center"><font face="Courier New, Courier, mono" size="3">Dim VarArray(2 
 to 9)</font></p>
 <p align="left"><font face="Arial, Helvetica, sans-serif" size="3">If you want 
 to put data into an array, you use the all-powerful equals sign. You get the 
 number of the block into which you want to store your data and put that in 
 parentheses - that is Salaries(0) - the first block. You then put an equals 
 sign and whatever value you want to be put into this block. Remember that 
 all strings (text) MUST BE IN QUOTATIONS!</font></p>
 <p align="left"><font face="Arial, Helvetica, sans-serif" size="3">All programming 
 languages also have If satements. Visual Basic (VB for short) is no exception. 
 Visual Basic's if statement can be molded, though, but it stays relatively 
 similar through all transformations. Look at the next two examples and see 
 how they are similar and how they are different.</font></p>
</div>
<blockquote> 
 <blockquote> 
 <blockquote> 
  <blockquote> 
  <blockquote> 
   <blockquote> 
   <blockquote> 
    <blockquote> 
    <blockquote> 
     <p><font face="Courier New, Courier, mono">If SomeVariable = 
     20 Then Form1.Caption = 12</font></p>
     <p><font face="Courier New, Courier, mono">If SomeVariable = 
     20 Then</font></p>
     <blockquote> 
     <p><font face="Courier New, Courier, mono">Form1.Caption = 
      12</font></p>
     </blockquote>
     <p><font face="Courier New, Courier, mono">End If</font></p>
    </blockquote>
    </blockquote>
   </blockquote>
   </blockquote>
  </blockquote>
  </blockquote>
 </blockquote>
 </blockquote>
</blockquote>
<p><font face="Arial, Helvetica, sans-serif">How are they the same? They do the 
 exact same thing - if the variable SomeVariable equals 20, set the caption of 
 form1 to 12. How are they different? The first If statement is on all one line. 
 The second is on three. When would you use the second one over the first? Let's 
 say that you need to check if the date is Saturday. If it is, you must do three 
 things - set the form's caption to "Saturday", tell the user that 
 it is Saturday, and then end the program. Going back to the statement that if 
 more than one instruction is printed on one line, Visual Basic will treat it 
 as one, we cannot put three different instructions on the same line as in the 
 first If statement example above. We would need to use the second one. When 
 you use more than one line in an if statement, you MUST end it with an End If. 
 If you do not, then Visual Basic will think the whole application is one big 
 if statement.</font></p>
<p><font face="Arial, Helvetica, sans-serif">You have heard of an If, Then, Else, 
 right? If you haven't, then an If, Then, Else statement is basically a standard 
 if statement as described above, but with an Else clause that says: if some 
 statement is not true, do something else. Below is the only example of an If, 
 Then, Else statement you can use. Else's cannot be put on one line, like an 
 if statement can.</font></p>
<blockquote> 
 <blockquote> 
 <blockquote> 
  <blockquote> 
  <blockquote> 
   <blockquote> 
   <blockquote> 
    <blockquote> 
    <blockquote> 
     <p><font face="Courier New, Courier, mono">If SomeVariable = 
     20 Then </font></p>
     <blockquote> 
     <p><font face="Courier New, Courier, mono">Form1.Caption = 
      12</font></p>
     </blockquote>
     <p><font face="Courier New, Courier, mono">Else</font></p>
     <blockquote> 
     <p><font face="Courier New, Courier, mono">Form1.Caption = 
      13</font></p>
     </blockquote>
     <p><font face="Courier New, Courier, mono">End If</font></p>
    </blockquote>
    </blockquote>
   </blockquote>
   </blockquote>
  </blockquote>
  </blockquote>
 </blockquote>
 </blockquote>
 <p> </p>
</blockquote>
<p><font face="Arial, Helvetica, sans-serif">Have you ever see a movie in, say, 
 French, and you want to know what it means? Then someone puts subtitles on the 
 screen? Comments are like subtitles. Comments are like subtitles. The Visual 
 Basic compiler overlooks them - that is it knows they are not code. They are 
 denoted by a single quote (') like this: <font face="Courier New, Courier, mono">'This 
 is a comment.<font face="Arial, Helvetica, sans-serif"> Comments are usually 
 written to tell a user looking at your code what is going on.</font></font></font></p>
<p><font face="Arial, Helvetica, sans-serif">Do you know those annoying messages 
 that pop up on your screen when your computer does something wrong? Those are 
 called Messageboxes. You can make them in Visual Basic just to annoy anyone 
 who is using your application. The function is MsgBox and it looks like this:</font></p>
<p align="center"><font face="Courier New, Courier, mono">Msgbox "[What you 
 want to say]", [buttons], "[title]"</font></p>
<p align="left"><font face="Arial, Helvetica, sans-serif">Where "what you 
 want to say" is the message you want in your little pop-up window, Buttons 
 are the buttons you want on your pop-up window (vbOkOnly for an OK Button, vbOkCancel 
 for OK and Cancel Buttons, vbYesNo for Yes and No Buttons), and title is the 
 caption of the little pop-up window.</font></p>
<p align="left"><font face="Arial, Helvetica, sans-serif">To test whether a user 
 has answered yes, no, ok, or cancel to your message box, you must assign it 
 to a variable. You can do this with:</font></p>
<p align="center"><font face="Courier New, Courier, mono">Dim Variable</font></p>
<p align="center"><font face="Courier New, Courier, mono">Variable = Msgbox ("Do 
 you want to exit?", vbYesNo, "Exit, anyone?")</font></p>
<p align="center"><font face="Courier New, Courier, mono">If Variable = vbYes 
 then Msgbox "You Pressed Yes"</font></p>
<p align="left"><font face="Arial, Helvetica, sans-serif">This code checks to 
 see if the user pressed the "yes" button. Use vbNo, vbOK, vbCancel 
 in place of vbYes to test if the user pressed the No, Ok, or Cancel buttons.</font></p>
<p align="left"><font face="Arial, Helvetica, sans-serif">The Input box is just 
 like the message box but it 1) requires a variable and 2) allows users to input 
 data instead of simply outputting data to the user. Here is an example of an 
 input box:</font></p>
<p align="center"><font face="Courier New, Courier, mono">Dim Variable</font></p>
<p align="center"><font face="Courier New, Courier, mono">Variable = InputBox 
 "Enter Your Name"</font></p>
<p align="left"><font face="Arial, Helvetica, sans-serif">This example opens a 
 small pop-up box with a textbox in it that says Enter Your Name. When the user 
 enters his or her name into the textbox and clicks OK, the data the user entered 
 is stored in the variable Variable for further use.</font></p>
<p align="left"><font face="Arial, Helvetica, sans-serif">As described before, 
 a subroutine is not part of the main program. Therefore, it does not always 
 run automatically. Let's say that you declared a subroutine like:</font></p>
<blockquote> 
 <blockquote> 
 <blockquote> 
  <blockquote> 
  <blockquote> 
   <blockquote> 
   <blockquote> 
    <blockquote> 
    <blockquote> 
     <p><font face="Courier New, Courier, mono">Public Sub Hello()</font></p>
     <blockquote> 
     <p><font face="Courier New, Courier, mono">Msgbox "Hello. 
      How are you?"</font></p>
     </blockquote>
     <p><font face="Courier New, Courier, mono">End Sub</font></p>
    </blockquote>
    </blockquote>
   </blockquote>
   </blockquote>
  </blockquote>
  </blockquote>
 </blockquote>
 </blockquote>
</blockquote>
<p><font face="Arial, Helvetica, sans-serif">(Note the Public, and the End Sub 
 - two NEEDED parts of a subroutine. Also note the () or empty parentheses. This 
 subroutine takes no arguments.) This will not run at the beginning of the program. 
 Therefore, you have to <i>call</i> it. To do this, use, logically enough, the 
 call statement. You can use it thusly: <font face="Courier New, Courier, mono">Call 
 Hello<font face="Arial, Helvetica, sans-serif">.</font></font></font></p>
<p><font face="Arial, Helvetica, sans-serif">Loops are also an important part 
 of Visual Basic. There are many types of loops, but we will be covering only 
 two in this tutorial: the For Loop and the Do While loop. Here are examples 
 of each:</font></p>
<blockquote> 
 <blockquote> 
 <blockquote> 
  <blockquote> 
  <blockquote> 
   <blockquote> 
   <blockquote> 
    <blockquote> 
    <blockquote> 
     <p><font face="Courier New, Courier, mono" size="3">Do While 
     Counter < 100</font></p>
     <blockquote>
     <p><font face="Courier New, Courier, mono" size="3"> Msgbox 
      "Hello. How are you?"</font></p>
     <p><font face="Courier New, Courier, mono" size="3">Counter 
      = Counter + 1</font></p>
     </blockquote>
     <p><font face="Courier New, Courier, mono" size="3">Loop</font></p>
     <p><font face="Courier New, Courier, mono" size="3">For Counter 
     = 1 to 100</font></p>
     <blockquote> 
     <p><font face="Courier New, Courier, mono" size="3">Msgbox 
      "Hello. How are you?"</font></p>
     </blockquote>
     <p><font face="Courier New, Courier, mono" size="3">Next Counter</font></p>
    </blockquote>
    </blockquote>
   </blockquote>
   </blockquote>
  </blockquote>
  </blockquote>
 </blockquote>
 </blockquote>
</blockquote>
<p><font face="Arial, Helvetica, sans-serif" size="3">Do you know what they do? 
 The Do While loop only executes the message box if Counter < 100. In Do While 
 loops, you need a line like Counter = Counter + 1 to avoid an <i>infinite loop</i> 
 or a loop that simply executes for ever - to infinity. This line increases the 
 counter's value by one each time the loop loops. Therefore, after a while, counter 
 will be greater than 100 and the loop will end. It is a good idea, though, to initialize the counter using the equals sign like: counter = 0 before the loop starts. This tells Visual Basic where the counter should start counting at. The "Loop" at the end of this loop 
 tells the computer to start the process over again with the new value of counter. 
 The For loop, on the other hand, does not require a line like this. It says: 
 Execute the message box as Counter increases its value from 1 to 100. To prevent 
 an infinite loop, you simply put Next Counter at the end. This increases the 
 value of counter by one each time the loop loops.</font></p>
<p><font face="Arial, Helvetica, sans-serif">Now you should know a little about 
 the programming language of Visual Basic. Next, you will learn how to create 
 forms, objects, and programs using the Visual Basic compiler. Go on to the next 
 section to continue.</font></p>
<p> </p>
<p><font face="Arial, Helvetica, sans-serif"><a href="#_top">Go Back to the Top</a></font></p>
<p> </p>
<p align="left"><a name="_compiler"></a><font face="Arial, Helvetica, sans-serif" size="6">The 
 Visual Basic Compiler</font></p>
<p align="left"> </p>
<p align="left"><font face="Arial, Helvetica, sans-serif" size="3">This section 
 of the tutorial will teach you the basics of the Visual Basic compiler. The 
 Visual Basic compiler is a RAD application. No, this does not mean it is cool 
 - it means it is a Rapid Application Development system. You can create Visual 
 Basic applications faster than any other language because of its easy-to-use 
 and straight-forward compiler environment. </font></p>
<p align="left"><font face="Arial, Helvetica, sans-serif" size="3">Let's take 
 a look at the Visual Basic compiler and its parts:</font></p>
<p align="center">SCREENSHOTS AT: http://www.geocities.com/campbell_donalde/screenshots/intro</p>
<p align="left"><font face="Arial, Helvetica, sans-serif" size="3">This is the 
 New Project window. It will start EVERY TIME YOU OPEN THE VISUAL BASIC COMPILER. 
 Visual Basic can create multiple different types of applications - Standard, 
 ActiveX, ActiveX Controls, DLL's, Database Programs, Wizards, etc. For most 
 Visual Basic programs you will be writing, you should select Standard EXE and 
 Click Open. Next you will come to this screen:</font></p>
<p align="center">SCREENSHOTS AT: http://www.geocities.com/campbell_donalde/screenshots/intro</p>
<p align="left"><font face="Arial, Helvetica, sans-serif" size="3">This is the 
 actual Visual Basic compiler screen. First, read each and every one of the little 
 tags assigned to the windows. The Project Explorer is the window that lets you 
 move through your project. A Visual Basic project consists of Modules, which 
 house subroutines and variable declarations, Forms, which house your actual 
 program (what the user will see when they run your program), and any other file 
 needed for you to run your program. The Toolbox is where you find the different 
 objects. Some objects include Command Buttons, Textboxes, radio buttons, check 
 boxes, dropdown boxes, pictures, OLE controls, timers (which act like loops), 
 and Shapes - which are purely for decoration. The properties window lets you 
 set properties for objects. Remember from the beginning of this tutorial that 
 Caption is a property? Do you see the Caption property in the Properties window? 
 Setting this is the same as saying Form1.Caption = "something." To 
 set the properties of a certain object, simply click on the object you want 
 edit and insert a value for that property. The Form is the actual project. Think 
 of this as a sketching pad. This is where you will be putting your objects.</font></p>
<p align="left"><font size="3" face="Arial, Helvetica, sans-serif"><a href="#_top">Go 
 Back to the Top</a></font></p>
<p align="left"> </p>
<p align="left"><a name="_firstprogram"></a><font face="Arial, Helvetica, sans-serif" size="6">Your 
 First Program</font></p>
<p align="left"> </p>
<p align="left"><font face="Arial, Helvetica, sans-serif" size="3">Now, let's 
 open the Visual Basic compiler and make your first program. In some computer 
 lingos, the first program is normally a "HelloWorld" program, where 
 the programmer is taught basic Input and Output (keyboard and monitor) operations 
 (in our case, the command button, the message box, the input box, and the textbox.) 
 To create your first program, follow the steps below:</font></p>
<ol>
 <li><font face="Arial, Helvetica, sans-serif" size="3">Open the Visual Basic 
 compiler</font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3">Select Standard EXE and 
 click "Open"</font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3">Make sure your toolbox 
 is showing. Click on the icon that looks like a three-dimensional square </font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3">SCREENSHOTS AT: http://www.geocities.com/campbell_donalde/screenshots/intro. Then, go to your form window and lay your cursor on top of Form1. 
 See how the icon forms a crosshair? This is used to draw a commandbutton.</font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3" color="#000000">Click 
 and drag to form a square the size you want your commandbutton to be. When 
 the square is the appropriate size, let go of the mouse and the commandbutton 
 will appear. Click on it.</font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3" color="#000000">In the 
 properties window (F4 to make it appear,) goto the Caption property. Set it 
 to "HelloWorld." Also, note the value of the Name property for this 
 commandbutton. </font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3" color="#000000">Double-Click 
 on your commandbutton. The <i>Code</i> window will appear. Below is a picture 
 of the code window. Under it are the explanations for the various parts of 
 the code window. You should become very familiar with these.</font></li>
</ol>
<p align="center">SCREENSHOTS AT: http://www.geocities.com/campbell_donalde/screenshots/intro</p>
<ol>
 <li><font face="Arial, Helvetica, sans-serif" size="3">Note the following parts: 
 OBJECT: this is object with which the code is associated. Because you have 
 just double-clicked on the commandbutton, which is by default named Command1, 
 the code you type into this window will be associated with your commandbutton 
 (Command1.) EVENT: this is a drop-down box. It lets you select at what time 
 you want your code to be executed. Let's say that you want to display a messagebox 
 with "Hello" in it when the user rests his cursor over object Command1. 
 You would double-click on Command1 and select from this drop-down box the 
 event MouseOver.</font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3">Now to start. You have 
 just double-clicked on your commandbutton. Its default event is _Click(), 
 which tells the computer to execute your code when someone clicks on the commandbutton. 
 In this program, you will ask the user his/her name with an inputbox, then 
 say "Hello" and the person's name in a messagebox. You want all 
 of this to happen when the user clicks on your command button. Make sure that 
 Private Sub Command1_Click() appears somewhere on the screen. </font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3">Under this line, but 
 above the line End Sub, type in the following code:</font> 
 <blockquote> 
  <blockquote> 
  <blockquote> 
   <blockquote> 
   <blockquote> 
    <blockquote> 
    <blockquote> 
     <p><font face="Courier New, Courier, mono" size="3">Dim Name 
     as String</font></p>
     <p><font face="Courier New, Courier, mono" size="3">Name = InputBox("What 
     is your name?")</font></p>
     <p><font face="Courier New, Courier, mono" size="3">Msgbox "Hello 
     " & Name</font></p>
    </blockquote>
    </blockquote>
   </blockquote>
   </blockquote>
  </blockquote>
  </blockquote>
 </blockquote>
 </li>
 <li><font face="Arial, Helvetica, sans-serif" size="3">Note the ampersand (&.) 
 This tells Visual Basic that you want to add something to something. In this 
 case, you want to add the person's name to the line "Hello." If 
 you were working with numbers and wanted to add them together arithmatically, 
 you would use the + sign, not the ampersand (&.)</font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3">Now, run the program 
 (hit F5.) Click on the commandbutton. Does a window with a textbox appear 
 that says: "What is your name?"</font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3">If so, enter your name 
 and Click OK.</font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3">Does a messagebox appear 
 saying "Hello Jane" (if your name is Jane)? If so, you have written 
 your first Visual Basic program! Congradulations!</font></li>
</ol>
<p><font face="Arial, Helvetica, sans-serif" size="3"><a href="#_top">Go Back 
 to the Top</a></font></p>
<p> </p>
<p><a name="_wheretogo"></a><font face="Arial, Helvetica, sans-serif" size="6">Where 
 to Go From Here</font></p>
<p> </p>
<p><font face="Arial, Helvetica, sans-serif" size="3">Really, you can go endless 
 places. The best way to teach yourself is to read more tutorials, and just take 
 maybe an hour or so each week (at the bare minimum) to try different snippets 
 of code. If anyone gives you code, try it out, go through it, learn what it 
 does, and try to replicate it in a BRAND NEW VISUAL BASIC STANDARD EXE FILE. 
 </font></p>
<p><font face="Arial, Helvetica, sans-serif" size="3">Also, you can read some 
 interesting tutorials at: <a href="http://www.planet-source-code.com/vb">planet-source-code.com</a> 
 or <a href="tutorials.html">read some of my tutorials here</a>. Either way, 
 you are getting more practice in Visual Basic.</font></p>
<p><font face="Arial, Helvetica, sans-serif" size="3">Also, try a variety of VB 
 code. VB can offer:</font></p>
<ul>
 <li><font face="Arial, Helvetica, sans-serif" size="3">Database Applications</font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3">Internet Applications</font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3">Enrichment of Webpages</font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3">Networking Applications</font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3">Graphics Applications</font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3">DirectX Programming</font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3">Game Programming</font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3">Spy Software (<a href="spytut2.html">see 
 my tutorial</a>)</font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3">Security Software (<a href="spytut.html">see 
 my tutorial</a>)</font></li>
 <li><font face="Arial, Helvetica, sans-serif" size="3">And more!</font></li>
</ul>
<p><font face="Arial, Helvetica, sans-serif" size="3"><a href="#_top">Go Back 
 to the Top</a></font></p>
<p align="center"> </p>
<blockquote> 
 <div align="left"></div>
</blockquote>
<div align="center">
 <p align="center"> </p>
</div>
<center>
<h1>PLEASE RATE!</h1>
</center>
</body>
</html>
Original Comments (3)
Recovered from Wayback Machine