Lecture Topics in HCI, by Saul Greenberg
Back to: Windowing Systems and Toolkits

Examples of Visual Basic

Try downloading these visual basic projects.

Project 
(as downloadable zip file)
Description Authour
vbHelloWorld.zip A simple hello world program that illustrates a basic VB program as well as the command button and timer control. Saul Greenberg
FirstProject.zip We use this nonsense program as a first VB exercise for students to do.
  
The left figure shows when it looks like when the program is executed, while the right shows what happens after the user has clicked the button 3 times and selected the checkbox, and moved the mouse over the form. Try to program this yourself. It uses a command (or button), a label, and a checkbox. 
James Tam
vbImages.zip These two vb Projects illustrates two ways to cycle through images stored in a local directory. Each demonstrates different controls for accessing files, while both show a control for displaying images. Saul Greenberg
vbMarquee.zip A marquee (an automatically scrolling text region) is used to illustrate a Timer, a status bar and a checkbox control, and simple graphical repositioning, Saul Greenberg
vbMoveList.zip An example of how to use listboxes (as well as how to put images into buttons). This example lets you move items between lists. Rod Stephens, modified by Saul Greenberg
playsound.zip Illustrates how to play a wave file in Visual Basic. It works by declaring a function to the WIN32 API sndPlaySound . 
Don't be intimidated: its two lines of code!
Saul Greenberg
vbSketchpads.zip Illustrates two simple sketchpads. The first one is only about 6 lines of code, and just illustrates some very basic graphics and event handling. The second shows how one can dynamically create controls at run time (the items on the palette), how controls can be positioned at runtime, and how controls can be resized when the window is resized. Its a longer program, but well worth going through to see how these features work.

 

Saul Greenberg
drawpad.zip A simple object-oriented drawing editor that allows a user to create, move and erase squares. You can easily extend this to include different graphical classes e.g., circles, lines, etc., or to any interactive graphics. The program illustrates
  • how to do simple object-based interactive graphics in VB
  • how to use a collection
  • how to use a class
Saul Greenberg
vbDragPicture.zip Illustrates how to Bitblit a picture on another picture, and how to drag it around.  Rod Stephens
vbDragTreeNode.zip Illustrates how to use the Tree control and how to drag items around different parts of the tree  Rod Stephens
vbMoveControls.zip An example application that lets a user interactively move different kinds of controls on a display.  Illustrates interactive graphics. Saul Greenberg
rangeSlider-ActiveXControl.zip Illustrates a very crude range slider written in ActiveX. I include it to
  • show you how you can do interactive graphics (well, at least some simple stuff), 
  • how you can make an active x control that you can include in a project. 

It is limited. It does not scale its size, and I did not spend any time doing all the things that one normally does to package up a control. This is really just a quick hack. Feel free to improve it and pass it on to the class.

To use: Unzip the file into a directory. Check out the test program in a sub directory that I included. In your own project, you can include the range slider by going into  project/components and then selecting Browse. Navigate to the OCX file that will be in the unzipped directory and select it. You will see a new control that you can select.

Saul Greenberg
vbclassexample.zip Illustrates how to create a simple class that raises events Saul Greenberg
flexdata-example.zip Illustrates a database with the flex control. The database
just has two fields: name and phone. This example lets you add and remove records. To make the grid sorted, we set the data control's record source property to the SQL statment: Select * from friends order by FirstName. The record is just added to the end of the file, but the flex grid shows it sorted.
Shaun Kaasten


Last updated Fall 2000, by Saul Greenberg