The HelloWorld form code will take a few more changes. Select the Design window and add a GroupBox from the Toolbox. Here's what the VB.NET Express Help says about this control:
Use a GroupBox to logically group a collection of controls on a form. The GroupBox is a container control that can be used to define groups of controls.
The typical use for a GroupBox is to contain a logical group of RadioButton controls. If you have two GroupBoxes, each of which contain several option buttons (also known as radio buttons), each group of buttons is mutually exclusive, setting one option value per group.
That's exactly what we're going to do. So add three RadioButton controls inside the GroupBox. Again, remember to rename them as they're added. I used the name LanguageGroup for the GroupBox and English, Español, and Deutsch for the RadioButton controls. Change the Checked property of the one you want as a default selection to True.
In Part 1, we learned about event subroutines. When the Button control in the first program was clicked the Click event was triggered and the DisplayHello_Click subroutine was automatically executed. We'll continue to use this code in our new program but instead of displaying the message directly, the subroutine in HelloModule will be called and the variable Language is passed to it so the subroutine in HelloModule will know what language to use.
HelloModule.SayHello(Language)
In addition, we have to capture the language selection whenever one of the RadioButton controls is selected. We'll use the CheckedChanged event for each of the three RadioButton controls to do that. Here's the code for just one of them. The others are similar. I reformatted the lines with continuation characters (the space and underscore at the end) just to make it easier to read.
Private Sub English_CheckedChanged( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles English.CheckedChanged
Language = "English"
End Sub
Notice that we need a variable (Language) to hold the language selection. Because it must be referenced by all of the CheckedChanged events, I declared it outside the subroutines. This gives the variable module scope. We'll discuss what is called scope of variables in greater detail later too. In my program, I also changed the Text property of the controls to make everything look better.
The new code and the HelloWorld form are shown below:
--------
Click Here to display the illustration
Click the Back button on your browser to return
--------
At this point, you should be able to run the new, modular Hello World by pressing F5 or clicking the Run icon. Click here to download the complete code.
There are a lot of improvements that can be made. For example, the Button control is always in English even though the rest of the form is in the target language. See if you can figure out how to change the button whenever a different language selection is made.
In the next part of the course: What's New With Visual Basic .NET Express, we get up to speed on VB Express and what's new and different in it.

