0% found this document useful (0 votes)
8 views

Visual Basic Examples

Uploaded by

vickroid007
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Visual Basic Examples

Uploaded by

vickroid007
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

2/4/2016 Visual Basic Examples

Saul Greenberg

Research Courses Administration Prospective students

Vitae Personal HCI Resources Internal

Saul Greenberg > courses > HCI topics > visual basic

Visual Basic Programming Examples

Other VB resources Tutorials Programs ActiveX Controls Third Party Examples

These pages collect example tutorials, programs and ActiveX controls displaying particular
programming techniques in Visual Basic.

Further Assistance
We cannot offer any further help with these examples. Most were developed by
students who are no longer present. Our current students have moved onto
programming in C#, and thus no longer use VB. Please do not contact us for further
help, although feel free to tell us that this page was useful to you!

Other VB resources
Planet Source Code.com has lots of searchable example programs and tutorials
E­Commerce Webopedia: ActiveX controls is a page of links, but not sure how good it is for
VB

Tutorials
These tutorials contain step by step graphical guides to several visual basic programming
concepts and tools. Note that they are not necessarily in progressive order!

Tutorial Description Authors


#1 Introduction to Visual Basic Part 1 Mike Rounding
James Tam
A very basic demonstration and example of some controls and events
A simple example of how to program a listbox
MSDN: what it is, how to get at it
MSDN sample programs online: how to get at'em

#2 Introduction to Visual Basic Part 2. Mike Rounding


James Tam
Database example using the Data control
Saul Greenberg
Saul's Sketchpad demo
Saul's Advanced Sketchpad demo

#3 Accessing databases using the ADO Data Control Mike Rounding


James Tam

#4 Accessing databases using the Data Environment Mike Rounding


James Tam
control
#5 Creating a simple HelloWorld ActiveX control in Visual Saul Greenberg

Basic

#6 How to register your ActiveX Controls on the Computer Mike Rounding

http://pages.cpsc.ucalgary.ca/~saul/vb_examples/ 1/7
2/4/2016 How to register your ActiveX Controls
Visual Basic Examples on the Computer
Science machines
#7 Building a Ticker ActiveX Control with the ActiveX Mike Rounding
Rod Stephens
Control Wizard
#8 Building a Transparent ActiveX Control that lets you Mike Rounding
Shaun Kaasten
click on a non­rectangular image
#9 Dynamic queries and databases: simple example on Mike
how you can use sliders to build a query to a database Rounding
# 10 The "Bitton" control, beginning guide to building Mike
ActiveX controls a few different ways along with some Rounding
ActiveX explanation
# 11 This program demonstrates dragging and dropping Mike
from explorer and between forms and also includes a Rounding
cool control moving code module. Saul
Greenberg
# 12 This is a step­by­step tutorial for how to integrate Mike
Macromedia Flash into your VB applications. Complete Hornby­
with instructions on how to pass information back and Smith
forth and also how to remotely invoke Flash methods
right in VB!

Programs
Project Description Authors
vbHelloWorld A simple hello world program that illustrates a Saul Greenberg

basic VB program as well as the command


button and timer control.
FirstProject We use this nonsense James Tam

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.

http://pages.cpsc.ucalgary.ca/~saul/vb_examples/ 2/7
2/4/2016 Visual Basic Examples

vbImages These two vb Projects illustrates two ways to Saul Greenberg

cycle through images stored in a local


directory. Each demonstrates different controls
for accessing files, while both show a control
for displaying images.
vbMarquee A marquee (an automatically scrolling text Saul Greenberg

region) is used to illustrate a Timer, a status


bar and a checkbox control, and simple
graphical repositioning,
vbMoveList An example of how to use Rod Stephens,
modified by
listboxes (as well as how to Saul Greenberg

put images into buttons). This


example lets you move items
between lists.

vbPlaysound Illustrates how to play a wave file in Visual Saul Greenberg

Basic. It works by declaring a function to the


WIN32 API sndPlaySound .
Don't be intimidated: its two lines of code!
vbSketchpads Illustrates two Saul Greenberg

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.
See Tutorial 2 for step by step instructions for how
these programs work.

vbDrawpad A simple object­oriented drawing editor that Saul Greenberg

allows a user to create, move and erase


squares. You can easily extend this to include
http://pages.cpsc.ucalgary.ca/~saul/vb_examples/ 3/7
2/4/2016 Visual Basic Examples

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
vbDynamicQueries This program is similar to the drawing editor Saul Greenberg

above, but used for completely different

purposes. It illustrates
how to do dynamic
queries on city attributes,
where cities on a map are
filtered immediately as a
person moves a slider or
checks a checkbox. While the example is
simple, the possibilities of how you can
enhance it are endless.
Click on the image to view it in full size.

vbTableLens Illustrates how to create a very simple Rod Stephens

table lens that toggles cells between


graphical and textual views.
Click on the image to view it in full size.

vbDragPicture Illustrates how to Bitblit a picture on another Rod Stephens

picture, and how to drag it around.


vbDragTreeNode Illustrates how to use the Tree control and Rod Stephens

how to drag items around different parts of


the tree
vbMoveControls An example application that lets a user Saul Greenberg

interactively move different kinds of controls


on a display. Illustrates interactive graphics.
vbclassexample Illustrates how to create a simple class that Saul Greenberg

raises events
vbFlexdata­ Illustrates a database with the flex control. Shaun Kaasten

example 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
http://pages.cpsc.ucalgary.ca/~saul/vb_examples/ 4/7
2/4/2016 Visual Basic Examples

the flex grid shows it sorted. See also Tutorial


3 and Tutorial 4 for other ways to access
databases.

vbShapedControls Illustrates how you can clip the shape of Shaun Kaasten

a control or form to a variety of regions.

ActiveX Controls
Project Description Author
HelloWorld A tutorial and example project Saul Greenberg

that shows you how to build a


minimalist VB ActiveX Control
Component. It just contains a
label saying "Hello World" and
has no code attached to it.
However, it does have a toolbox control icon.
Includes an example program.
TickerTape A tutorial and example project that shows you Mike Rounding
Rod Stephens
how to build a TickerTape control out of a label.
It also illustrates the ActiveX Control Wizard.
ElusiveProfessor A VB ActiveX Control that creates a 'new' type Saul Greenberg

of button (actually a standard but augmented


command button) that moves away from the
person who is trying to click it. Includes an
example program. The design was based upon
a class project where students had to design a
button that reflected their personality.
FollowMe This program creates a command button that Michael
Rounding
will follow the mouse around.
This simple but very useful example illustrates
using the Extender object in a VB
UserControl to access outside properties
and methods
the use of calls from the Win32 API for
finding mouse cursor coordinates
scaling those coordinates in terms of a
container object (be it a form or another
control container)
vbRangeSlider Illustrates a very crude range slider written in Saul Greenberg

http://pages.cpsc.ucalgary.ca/~saul/vb_examples/ 5/7
2/4/2016 Visual Basic Examples

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.

PictureClip A tutorial program that shows you how to use Dave Miller,
581 student
the PictureClip component for creating
animations.

ShowNeighbours An activeX control plus exe that shows you how Chris Bradley,
581 student
to find the other controls in a form from inside
an ActiveX control. Saul Greenberg used this
example to build a Mr. Popularity button, where
all the other controls on the form gravitate
towards a Mr Popularity ActiveX button.
xparent.zip Illustrates how you can build a Mike Rounding,
Shaun Kaasten
transparent ActiveX Control
that lets you detect clicks on a
non­rectangular image (in the
figure on the right these would
be the red letters). See Tutorial
8.
tranparent.zip Similar to xparent.zip, except this version Mike Rounding,

follows your mouse wherever it goes around


the screen ­ very fun.
MovingControl.zip This example includes a user control that will Mike Rounding

move itself towards any other control. This


example illustrates some custom events and
properties in a user control, and shows how to
do do simple control animation with a timer.

Third Party Examples


We've found these on the web or in books, and they are too good not to include

Project Description Author


http://pages.cpsc.ucalgary.ca/~saul/vb_examples/ 6/7
2/4/2016 Visual Basic Examples

(as zip or .bas)


animation Bitmap Animation: Shows how to build a simple Rod
Stephens
bitmap animation.
Transparent.zip Transparency: A tool library to do transparency, Doug Gaede

including transparent controls.


vbRangeTool.zip An ActiveX control Author
unknown
that implements a
range slider. Looks
pretty good!

VB­ Capturing bitmaps: A BAS library for capturing Microsoft


website
ScreenCapture.BAS various portions of a screen.

http://pages.cpsc.ucalgary.ca/~saul/vb_examples/ 7/7

You might also like