Visual Basic 1
Visual Basic 1
Basics
Index of project examples in this
ppt
My CSCI 110 powerpoints will have an index
of the VB examples generally as the 2nd
slide. For this ppt show, here is an index
of project examples
• The Two-textboxes example
• A Messagebox example
• The F to C converter
• Gaddis/Irvine text comments and chapter
1 screenshots
About the Schneider text examples
• VB 2005 Express edition can be downloaded
free from MS to install on your own machine.
• You will need the 2005 edition VB to run the
examples on the (other) text CD.
• However, my examples and the text examples
should run in the labs, which have this edition of
VB.
• As the semester progresses I will update our
labs, projects and these powerpoints to reflect
more examples from our text.
Here’s a VB form example: hourly wage
calculations. We will write this program next week.
About VB
• VB is a (sort of) object-oriented language
with a large IDE providing much developer
support.
• Because of this, the environment is as
hard to learn as the language, or harder!
• But it won’t be hard to develop impressive
VB projects right away.
VB IDE
• IDE means integrated development
environment.
• An IDE provides a means of developing
and test-running software.
• The VB IDE is “part of” MS’s large .NET
software system.
• There is quite a lot of mid-size enterprise
sw development going on in VB!
VB version etc
• Labs should have the 2005 version of VB
in the programming folder.
• This large program will take a while to load
and VB programs will generally run fairly
slowly from within the IDE.
• You can download free .NET software for
your home computer from Microsoft.
To run VB: Click on the MS studio.net icon
(probably in the programming folder)
Select windows application
Select new project (windows application), then
select VB project from other types and click ok.
Note: You can give a project a special name by typing
something else where it says name when you select New
Project. This is a good idea, because it will get hard to
remember what’s what.
Creating a VB application in the express
edition…view toolbox selected
A button with the hot key (alt-P)
defined
Selecting new vb project (as per above)
will open the form design interface
Selecting “View” on menu bar opens various
window “view” options. Here, “view toolbox”
was selected.
Pull down the View options on the
menubar
• Use the toolbox to select “tools” (called
“controls” in VB) for your project
• Use the properties window(s) to set
properties for your form and its control
components.
• Use the solution explorer window to view
the different elements of your solution.
Plopping components on your form
• Either double clicking a component in the
toolbox menu, or clicking the component in
the toolbox then clicking on your form, will
put a control on your form.
• Once there, you can “select” it, resize it,
align it, or drag it to where you want it to
go, or add other properties to it like tab
order or a tooltip.
Here’s a form with a couple of
textboxes plopped on it
Some popular components
• Textboxes, buttons, and labels are the most
popular components. Textboxes hold text - often
user input.
• Labels are for labeling other components,
usually.
• Buttons can be “pressed” to fire an event.
• Picture boxes can “hold” images
• comboboxes allow multiple choices.
• Listboxes are like multi-line textboxes,
(Textboxes can also be set to be multiline).
• Radiobuttons and checkboxes display available
choices: the user can select/deselect them
More on controls
• Controls can be grouped into groupboxes
to help rationalize a complicated display.
• There are other types of controls as well –
we won’t learn how to use them all this
semester.
• You are already familiar with many
controls as a user of window applications.
Running your VB application
• At any time during development, as long
as you have no errors, you can “run” your
application.
• To check for errors: Select build from the
menubar and then select build solution
(or rebuild)
• To run or check for errors: Select Debug
on the menu bar, and then pick start or
press F5.
Running an application with two textboxes
(there’s no functionality)
Note
• You need to close your running
application (window) before continuing
development on it. Just click the X in the
upper right corner of the running form’s
window or, in the debug menu, select
“stop debugging”.
• It is useful to “build” or “debug” periodically
to make sure you have what you want and
what you have works.
Selecting the form and editing the text property in
the properties window allows you to change the
text displayed on the form, its “name”, when the
form comes up
More “basic” development: Let’s
add functionality to a form
• In any case, you can edit the stub to look like this:
End Sub
Our sub