Академический Документы
Профессиональный Документы
Культура Документы
Create a project which contains a form that can be used as a ‘login’ form to an application. Write an appropriate If-Then-Else block for the following situation:
Place a label, a text box, and a command button on the form. Ensure that the text box Test the string variable Flag. If Flag=’True’, set count equal to 0 and assign the message
receives focus on startup. “Resetting the Counter” to the string variable Msg1. Then test the value of the single-
Place code in the Click event of the command button, so that the entry in the text box is precision real variable Z.
validated against a password you have selected (use a simple If statement).
If the password is correct, then display a message box congratulating the user on their If Z exceeds Zmax, assign the message “Maximum Value Exceeded” to the string
correct choice. Use an Else statement to display a message box warning the user that they variable Msg2, and assign the value of Zmin to Z.
have entered an incorrect password. Otherwise, add the value of Zmin to Z.
Private sub Form_Load() If Flag = “False”, increase the value of count by 1, then test the string variable Type
Form1.Show If Type equals “A”, add the value of U to Z
Text1.SetFocus If Type equals “B” add the value of V to Z
End Sub Otherwise, add the value of W to Z
Finally, reset the value of flag to “True”
Private Sub Command_Click()
If Text1.Text = “Password” then
MsgBox “ Congratulations, this is correct” If Flag = "True" Then
Else Count = 0
MsgBox “Sorry, the password is not correct” Msg1 = "resetting the Counter"
Text1.Text =” “
Text1.SetFocus If Z > Zmax Then
End if Msg2 = "Maximum Value Exceeded"
End Sub Z = Zmin
Else
Z=Z+W
End If
Else
Q2. Count = Count + 1
Create a project with a form and a single command button. Write code so that if the If Type = "A" Then
command button is clicked, a running total of the number of times the command button has Z=Z+U
been clicked is maintained and displayed. Elseif Type = "B" Then
Z=Z+V
Else
Either declare a module level variable, or to declare a Static type variable Z=Z+W
End If