Sample Visual Basic .Net Programs

go to the programs

Instructions

The following are sample VB.Net programs. Each program is included with the full folder for the project in a single zip file. To run the programs or edit them you must do the following:

  1. Download the zip file by clicking on the filename
  2. You MUST unzip the file in order to run the program or modify the code
    (If you don't unzip the file then you will be able to open the .sln file - see next step - but it will not work correctly).
  3. To start editing the program in Visual Basic, double click on the file with the ".sln" extension.
    NOTE: when you double click on the .sln file you may get a dialog box similar to the following. Since windows doesn't know who created the program Windows assumes that it might have been a hacker and the program might contain a virus. This is NOT an issue for these programs so Click on the OK button to continue.
  4. Once you are in Visual Basic you can use the "Solution Explorer" to view the individual files in the project. If you don't see the Solution Explorer, choose the following menu choice: "view | Solution Explorer"
  5. Most programs have a single Form1.vb file. Double click on the Form1.vb file in the Solution Explorer window to see the main form for the application.

The Programs

  Files
(click zip file to download or
click .vb file to view the code)
Screen Shots
(click on a picture to see a larger copy)
Description Topics
1   Program demonstrates User Interface with labels, textboxes and buttons. There is no "code" for the program.
  • Creating textboxes, labels and buttons (no code)
2   Program displays a message when user clicks a button
  • MessageBox.Show
  • setting properties of a Button (e.g. color)
2b   Program uses a menu to display the message Hello World in a label in either English/French/Spanish. Also uses radio buttons to change the colors of the label.
  • menus
  • radio buttons
  • programatically setting properties of a Label (e.g. color)
3   Text properties of a button, label and textbox change when another button is clicked. Also a "TextChanged" event handler notifies the user when the text in a textbox is changed. The event handler will fire both when the text is changed automatically by the program and when the user types characters in the textbox.
  • Changing property values at runtime.
  • TextChanged event
4   User enters length and width of a rectangle and pushes a button to calculate the perimeter and the area.
  • TextChanged event
  • Val
  • accessing text property of textboxes and labels
5   User enters his age. Program determines if he can vote or eat ice cream.
  • Integer.Parse
  • If with an Else
6   User enters a number and program determines if the number is positive and/or even
  • Integer.Parse
  • Mod operator (used to determine if a number is even)
  • Separate If staements - not nested and without Else clauses
7   User enters a month and program displays the number of days in the month
  • Select Case
  • ToLower method of a String object
8   Program "draws" a picture of boxes made out of the letter "x".
  • Nested For Loops (4 deep)
9 Computes the sum of the digits in a number (e.g. the sum of the digits in the number 1322 is 8).
  • For loop
  • String.substring(position,length)
  • String.length
10   Console appliation. Asks the user to enter a list of numbers. Program redisplays the numbers and finds the largest number in the list.
  • Console application
  • Declaring arrays, eg. Dim myarray(100) as Integer
  • Loop through array elements
  • Passing an array to a ByVal parameter
11   Draw a line using a 2d array.  
11   Draw a line using a 2d array.  
12   Draw a line using a 2d array.