MaximumPC 2004 09

(Dariusz) #1
NO

The newly born Windows
Form, future home of our
GUI. Simple. Unassuming.
Gray. Very gray.

Windows Application on
the right of the dialog
box under the Templates
label. For simplicity’s sake,
we’ll call our program
“MaxPC02.” Once you click
the OK button, VS2003 will
create a new directory in
the My Documents\Visual
Studio Projects folder. This
directory will have the
same name as your proj-
ect and will contain all the
files that make up your
application.
The IDE has now entered the
WYSIWYG design view mode, and a
blank Windows Form named Form1
has been created. Look at the Solution
Explorer and you’ll see that the file rep-
resentation of Form1, named Form1.vb,
has been created as well. Form1 is our


GUI for this project, and will be the
canvas on which we create our pro-
gramming masterpiece. Form1 is
a lousy moniker for a work of art,
though, so let’s change it. In the
process, you’ll learn more about
the Visual Studio IDE as well as
Windows Forms.

SEPTEMBER 2004 MA XIMUMPC 67


The journey of a thousand miles begins with the
creation of a new VB.NET project.

Stepping through a GUI


From the time your program’s first form loads to the time it exits, this chart shows you every function


YES

NO

YES

(Cryptography.Decrypt)
Decrypt text

(ValidateKey)
Program
validates
key

Form1 exits

(btnExit_Click)
Exit button clicked

(Cryptography.Encrypt)
Encrypt text

(btnEncrypt_Click)
Encrypt button
clicked

(btnDecrypt_Click)
Decrypt button
clicked

The user starts the application
and Form1 loads into memory

When the Exit button is
clicked the btnExit’s click
event is triggered.

If the user has entered a valid key,
either the Decrypt or Encrypt method
is called. If an invalid key is entered,
neither method is called and the user
is presented with an error.

Once btnExit’s click is triggered, the application terminates.

Form1 loads

The application is ready
for use and waits for
input from the user.

Form1

The user clicks the Decrypt
button, which triggers
btnDecrypt’s click event. btn-
Decrypt’s click function starts
the ValidateKey function.

The function
that handles
the actual
encryption of
the text the
user entered.

The Encrypt button is
clicked and btnEncrypt’s
click event is raised.

(ValidateKey)
Program
validates
key
The function that
handles the actual
decryption of the
text the user
entered.
Free download pdf