
' Exit the program if the Exit button is clicked
Private Sub cmdExit_Click()
    End 
End Sub
' When the Submit button is clicked, put up a message box that welcomes them
Private Sub cmdSubmitName_Click()
    MsgBox ("Hello, " & txtUserName.Text & ".  Welcome to MOS!")
End Sub
Notice that to find out the user's name, we just used the Text property from the txtUserName control. When you're writing code, to get access to a property of a control, you type the Name of the control, followed by .propertyname. You can access any property from any control this way. Most properties from most controls can also be altered in code as well, as we'll see in the next example. The properties in our controls are a type of variable. A variable is a named location in main memory that allows us to store information. When we create a control, we automatically get variables to store their properties. Later we'll see how to create other variables to store information that is not attached to controls.
Here's a screen shot of the program as it is opened:

Here's a screen shot of the program after the name has been submitted:

Here's the part of the code that was changed from the previous example:
' When the Submit button is clicked, display a message.  It is displayed
' in a label by setting the Text for the label to the welcome message,
' then making the label visible.
' The message says hello, then the user's name (taken from the txtUserName
' TextBox), then Welcome to MOS!
Private Sub cmdSubmitName_Click()
    lblOutputMessage.Caption = "Hello, " & txtUserName.Text & ". Welcome to MOS!"
    lblOutputMessage.Visible = True
End Sub
The first line of this code is accessing the Text property of the label
called lblOutputMessage.  But instead of just using the value stored
there, this line of code is actually changing the value of the Text property.
The "=" is
called an assignment.  Any time you see an "=" in BASIC code, it means to
take the value on the right hand side, and actually store it
in the variable on the left-hand side.  This changes the value stored
in the variable while the program is running.  The second line is another
example of an assignment statement.  Assignment statements are extremely
important in programming, and we will use them often.