Public Class Form1
Dim M, F, A, T As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
M = TextBox1.Text
F = TextBox2.Text
A = TextBox3.Text
T = M + F + A
TextBox4.Text = T
Select T
Case Is >= 80
TextBox5.Text = ("A")
Case Is >= 70
TextBox5.Text = ("B")
Case Is >= 60
TextBox5.Text = ("C")
Case Is >= 50
TextBox5.Text = ("D")
Case Else
TextBox5.Text = ("F")
End Select
If T >= 80 Then
TextBox5.ForeColor = Color.Green
ElseIf T >= 70 Then
TextBox5.ForeColor = Color.Green
ElseIf T >= 60 Then
TextBox5.ForeColor = Color.Green
ElseIf T >= 50 Then
TextBox5.ForeColor = Color.Green
Else
TextBox5.ForeColor = Color.Red
End If
If T >= 80 Then
TextBox6.Text = "โห่!นายนี่เมพมากๆ"
ElseIf T >= 70 Then
TextBox6.Text = "เก่งฝุดๆเลยพี่น้องครับ"
ElseIf T >= 60 Then
TextBox6.Text = "C ก็จ๊าบแล้วพี่น้องครับ"
ElseIf T >= 50 Then
TextBox6.Text = "D นะที่ผ่านมาได้"
Else
TextBox6.Text = "คุณคือจุดอ่อน 555!"
End If
End Sub
Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox5.TextChanged
End Sub
End Class
IF Number > 70 AND Number <= 100 THEN
Grade ← "A"
ELSE IF Number > 50 THEN
Grade ← "C"
ELSE IF Number >= 0 THEN
Grade ← "F"
ELSE
Grade ← "Error"
END IF
เป็นต้น
หรือ
SELECT CASE Number
CASE 0 TO 50
Grade ← "F"
CASE 51 TO 70
Grade ← "C"
CASE 71 TO 100
Grade ← "A"
CASE ELSE
Grade ← "Error"
END SELECT