程式碼
Public Class Form1
Dim a, b, c, d
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Val(TextBox3.Text)
d = Val(TextBox4.Text)
If a > b And a > c And a > d Then
TextBox1.ForeColor = Color.Red
ElseIf b > a And b > c And b > d Then
TextBox2.ForeColor = Color.Red
ElseIf c > a And c > b And c > d Then
TextBox3.ForeColor = Color.Red
Else
TextBox4.ForeColor = Color.Red
End If
If a < b And a < c And a < d Then
TextBox1.ForeColor = Color.Green
ElseIf b < a And b < c And b < d Then
TextBox2.ForeColor = Color.Green
ElseIf c < a And c < b And c < d Then
TextBox3.ForeColor = Color.Green
Else
TextBox4.ForeColor = Color.Green
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox1.ForeColor = Color.Black
TextBox2.ForeColor = Color.Black
TextBox3.ForeColor = Color.Black
TextBox4.ForeColor = Color.Black
End Sub
End Class
蠻有代表性的If例子,Good!
回覆刪除jack