complete the program.
Dim strAge as String
Dim intAge as ......
StrAge=InputBox("How old are you?", "Age ask")
If(strAge="") Then
............ 'Terminates the application
End If
IntAge=Val(strAge)
Do.........((IntAge<1)or(intAge>99))
MsgBox "Age is between 1 and 99",
vbExclamation, "Error!"
StrAge=.........("How old are you?",
"Age Ask"),
If(strAge="") Then
........... 'Terminates the
application
End If
........... 'End the Do section
IntAge=Val(strAge)
........... Case IntAge
Case1..........6
Label1.Caption="You are under 7
years old."
Case7,8,9,10
Label1.Caption="You are under 11
years old."
Case Else
Label1.Caption="You are over 10
years old."
End...........
Here is the corrected version of the program:
```vb
Dim strAge As String
Dim intAge As Integer
strAge = InputBox("How old are you?", "Age ask")
If strAge = "" Then
End ' Terminates the application
End If
intAge = Val(strAge)
Do While intAge < 1 Or intAge > 99
MsgBox "Age is between 1 and 99", vbExclamation, "Error!"
strAge = InputBox("How old are you?", "Age ask")
If strAge = "" Then
End ' Terminates the application
End If
intAge = Val(strAge)
Loop
Select Case intAge
Case 1 To 6
Label1.Caption = "You are under 7 years old."
Case 7 To 10
Label1.Caption = "You are under 11 years old."
Case Else
Label1.Caption = "You are over 10 years old."
End Select
```
Explanation:
1. Declare variables:
- `strAge` as String: This variable will store the age entered as a string.
- `intAge` as Integer: This variable will store the age as an integer.
2. Prompt the user for their age using the `InputBox` function:
- `strAge = InputBox("How old are you?", "Age ask")`: This line of code displays an input box with the message "How old are you?" and the title "Age ask". The value entered by the user is stored in the `strAge` variable.
3. Check if the user entered an empty string:
- `If strAge = "" Then`: This line checks if the `strAge` variable is empty (user did not enter anything). If it is empty, the program terminates using the `End` keyword.
4. Convert the string age to an integer:
- `intAge = Val(strAge)`: This line converts the string value stored in `strAge` to an integer using the `Val` function.
5. Start a loop to check if the age is between 1 and 99:
- `Do While intAge < 1 Or intAge > 99`: This line starts a loop that will continue until `intAge` is between 1 and 99.
6. Display an error message if the age is not between 1 and 99:
- `MsgBox "Age is between 1 and 99", vbExclamation, "Error!"`: This line displays a message box with the message "Age is between 1 and 99" and an exclamation icon.
7. Prompt the user for their age again if an error occurs:
- `strAge = InputBox("How old are you?", "Age ask")`: This line displays the input box again to prompt the user for their age.
- `If strAge = "" Then`: This line checks if the user clicked the cancel button or entered an empty string. If so, the program terminates using the `End` keyword.
8. Convert the new string age to an integer:
- `intAge = Val(strAge)`: This line converts the string value stored in `strAge` to an integer.
9. End the loop section:
- `Loop`: This line marks the end of the loop section.
10. Use a `Select Case` statement to determine the age group and display a message based on the age:
- `Select Case intAge`: This line starts the `Select Case` statement and checks the value of `intAge`.
- `Case 1 To 6`: This line specifies the range of age values from 1 to 6. If `intAge` falls within this range, the following code block will be executed.
- `Label1.Caption = "You are under 7 years old."`: This line sets the caption of a label named "Label1" to "You are under 7 years old."
- `Case 7 To 10`: This line specifies the range of age values from 7 to 10. If `intAge` falls within this range, the following code block will be executed.
- `Label1.Caption = "You are under 11 years old."`: This line sets the caption of "Label1" to "You are under 11 years old."
- `Case Else`: This line specifies the default case when `intAge` does not fall into any of the previous ranges. The following code block will be executed.
- `Label1.Caption = "You are over 10 years old."`: This line sets the caption of "Label1" to "You are over 10 years old."
- `End Select`: This line marks the end of the `Select Case` statement.
11. End of the program: This is the end of the program.