Game Development Reference
n Next, you will find a comma-separated list of parameters inside a pair of
parentheses. Each parameter is declared the same way as all variables in VB
are declared. There is a modifier ( ByVal ), the name of the parameter
( sender ), the keyword As , and finally the parameter's type ( System.Object ).
Our code will ignore both parameters. (Note that these are preceded by an
underscore character; this is the line-continuation character in VB, used
when a single line of code spans multiple lines in text.)
n The Handles keyword tells the system that this routine is an event handler,
and the event it handles is what comes after the Handles keyword. The name
suggests to the programmer that this is the Load event handler, but the
Handles keyword is authoritative.
We will add our initialization code between the Sub and End Sub lines shortly. We
can ignore the complexities safely as long as we remember that the code we add
here will run when the form is loaded, which for us means once, at startup.
Our application will want to compute the correct value of maximum hit points
and show it as the text in the HitPointsLabel field instead of 888. To do this, the
code needs to compute the product of the level of the character times the size of
the character's hit dice. It would be nice if the radio buttons would directly tell us
the size of the character's hit dice, but they do not. The Level control will give us a
numeric value for level, but we need an integer variable to hold the die size. Just
like on a car radio, we have to program the number we want to associate with
each button. To make life easier, we will store that number away whenever a
button gets clicked.
Below the Public Class GameForm and above the handler for Load , type the
following and press Enter:
Dim dieSize as integer
Visual Basic will reformat and color the text as you go.
As you type, Intellisense will offer various options that you can select. Pressing Ctrlþspacebar
brings up Intellisense if it is not already there, and pressing Esc makes Intellisense go away. When
Intellisense offers an option list, you can scroll to the one you want and press Tab to select it. The
help system and Wikipedia can tell you more.
We want our software to ''wake up sane.'' That means the value shown for
maximum hit points should be based on the level and class selected on the user