146 Part II Programming Fundamentals
Your screen looks similar to this:
The first two statements in the event procedure transfer data entered in the text box
objects into the FirstNum and SecondNum variables.
'Assign text box values to variables
FirstNum = TextBox1.Text
SecondNum = TextBox2.Text
The TextBox control handles the transfer with the Text property—a property that accepts
text entered by the user and makes it available for use in the program. I’ll make frequent
use of the TextBox control in this book. When it’s set to multiline and resized, it can
display many lines of text—even a whole file!
After the text box values are assigned to the variables, the event procedure determines
which radio button has been selected, calculates the mathematical formula, and
displays the result in a third text box. The first radio button test looks like this:
'Determine checked button and calculate
If RadioButton1.Checked = True Then
TextBox3.Text = FirstNum + SecondNum
End If
Remember from Chapter 3 that only one radio button object in a group box object can
be selected at any given time. You can tell whether a radio button has been selected by
evaluating the Checked property. If it’s True, the button has been selected. If the Checked