Today, God willing, to explain the IF function
IF function In if used Anndma words we want the program choose from a number of things
For example, if the user wrote 1 shows the image of a child even wrote 2 shows pictures footmen, and so on
IF function formulas
Simplest form of the function is
IF then
Condition clause
End IF
This image is used if there is only one condition
For example
IF text1.text = 5 then
Text2.text = 10
End if
In this program if txt = 1 5 Van txt 2 = 10
The second photo
IF then
Condition clause
Else
If you do not check the condition clause
End if
Example
Work of the secret number \
First, open the Visual
Create a textbox and command
In the textbox is property passwordchar to star, or as you would like to show PIN
Type in the command this code
Private Sub Command1_Click ()
If Text1.Text = "12345" Then
Msgbox "good password"
Else
Msgbox "wrong password"
End If
End Sub
Explain code
If txt 1 = 12345 showed a message that your password incorrect
Otherwise showed a message that the password wrong
Msgbox meaning show a message to the user
Third formula which in the case of multiple conditions
If then
A result of the first condition
Elseif then
Result of the second condition
Elseif then
Thus,
end if
Now the work of students' grades Assessment Programme
Student is higher than the 85 winning franchise
Student and higher than the 75 winning is very good
Student and higher than the 65 winning is good
Student and higher than the 50 winning be acceptable
The winning student less than 50 have deposit
Now think about the program interface
Create a textbox to be placed by the degree students
Create a command button command
Now the code in command
Private Sub Command1_Click ()
If Text1.Text> = 85 Then
MsgBox "exellent"
ElseIf Text1.Text> = 75 Then
MsgBox "verygood"
ElseIf Text1.Text> = 65 Then
MsgBox "good"
ElseIf Text1.Text> = 50 Then
MsgBox "Acceptable"
ElseIf Text1.Text <= 50 Then
MsgBox "fail"
End If
End Sub
Now run the program and type the numbers to experience the program
0 التعليقات:
إرسال تعليق