MaximumPC 2004 09

(Dariusz) #1

How To...^ A step-by-step guide to tweaking your PC Experience


TIME TO COMPLETION
3:00
HOURS MINUTES

MA XIMUMPC


In part two of our Visual Basic programming how-to,


we show you how to add a GUI to the basic cryptography


app we wrote in May


O


ur inaugural programming How-To, “Learn Visual
Basic Programming” ( http://www.maximumpc.com/how_to/
reprint_2004-04-07.html ), appeared in May 2004 and
showed you the basics of creating your very own com-
mand-line Visual Basic.NET application. But command-
line apps aren’t always convenient or practical. You paid
damn good money for the eye candy that is Windows
XP—why waste that by running your app from a black and
white command-prompt window when you can fire it up
with a mouse click? Read on and we’ll show you how to
develop a GUI app using Visual Studio.NET’s Windows
Form Designer.

Remember that a GUI—a graphical user interface—is
a visual representation of a computer program. Virtually
every program you use on your computer sports a GUI.
Instead of typing long, unwieldy commands, you interact
with the program via objects like buttons, text boxes,
icons, and menus, which you manipulate using a device
such as a mouse, keyboard, or touch screen.
This month, we’ll leverage the work we did in part
one with the command-line interface for cryptography,
and create a GUI-based app that functions the same as
our last version.

A GUI


PROGRAM


BY BRYANT BRABSON


66 MAXIMUMPC SEPTEMBER 2004


1 Get your tools^2 Create your project


Before we can
write our first line
of code, we need
to start Visual
Studio 2003’s
integrated devel-
opment environ-
ment (IDE). Create
a new project by
first clicking File,
then New, and
finally Project.
Don’t be over-
whelmed by the
number of options
on the screen.
Just make sure
you select Visual
Basic Projects
on the left under
Project Types, and
that you select

DEFINING TERMS


IDE: Integrated development envi-
ronment. An IDE is an application
that combines developments tools
such as code editors, GUI builders,
compilers, and debuggers into a
single programming environment.
IDEs contain everything you need
to write a program.
WYSIWYG: What you see is what
you get. In a programming context,
WYSIWYG means that what you
see in the IDE when you’re coding
your app is the same thing you’ll
see when you run it.
FORM: When building .NET appli-
cations, a form is an application’s
user interface.

All you need to write Visual Basic code is a copy of Microsoft’s
Visual Basic .NET 2003. You can either order a 60-day trial DVD or
try the software online using your broadband Internet connection.
Information explaining how to do both can be found at http://msdn.
microsoft.com/vstudio/productinfo/trial/. If you already have a copy of
Visual Studio.NET, Visual Basic.NET is included as part of the Visual
Studio package.
We also like to keep Michael Halvorson’s book Microsoft
Visual Basic.NET Step by Step handy. It’s a great beginner’s
guide to programming in VB, and can answer all your Visual
Basic syntax questions. One more thing: You should bookmark
the Microsoft Developer Network at http://msdn.microsoft.com/ —it’s a
great reference.
It’s absolutely vital that you open the source code for this appli-
cation so you can look at it while you read this how-to! In the arti-
cle, we’ll explain high-level concepts, outline good programming
practices, and explain how certain code snippets work, but we also
have detailed explanations of Visual Basic syntax and a play-by-
play description of how each line of code works in the comments of
the source files for the program. The complete Visual Basic project
file and code are available in the Extras section of our CD-ROM, or
at http://www.maximumpc.com.

Tell us what you think!
This is the second in
a series of four Visual
Basic programming
how-tos. Next, we’ll
show you how to
encrypt text files using
our application. In the
meantime, we wel-
come your thoughts on
this article! Send your
opinions, or any ideas
for future How-Tos to
howto@maximumpc.
com.
Free download pdf