成績 2010 . 9 .27
成績 2010 . 9 .27
Dim score As Single
Dim over As Boolean
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If IsNumeric(TextBox1.Text) And IsNumeric(TextBox2.Text) And IsNumeric(TextBox3.Text) Then
If Val(TextBox1.Text) < 0 Or Val(TextBox1.Text) > 100 Then
over = True
TextBox1.ForeColor = Color.Red
End If
If Val(TextBox2.Text) < 0 Or Val(TextBox2.Text) > 100 Then
over = True
TextBox2.ForeColor = Color.Red
End If
If Val(TextBox3.Text) < 0 Or Val(TextBox3.Text) > 100 Then
over = True
TextBox3.ForeColor = Color.Red
End If
If over = True Then
Label4.Text = "資料輸入錯誤,請重新輸入 0 到 100 之間"
Label4.BackColor = Color.Green
Button1.Enabled = False
Else
score = (Val(TextBox1.Text) + Val(TextBox2.Text) + Val(TextBox3.Text)) / 3
Label4.Text = score
If score < 60 Then
Label4.BackColor = Color.Red
End If
End If
Else
Label4.Text = "資料輸入錯誤,成績中有一個非數字"
Label4.BackColor = Color.Green
Button1.Enabled = False
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()
Label4.Text = ""
Label4.BackColor = Color.Empty
over = False
TextBox1.ForeColor = Color.Black
TextBox2.ForeColor = Color.Black
TextBox3.ForeColor = Color.Black
TextBox1.Focus()
Button1.Enabled = True
End Sub
End Class
Dim over As Boolean
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If IsNumeric(TextBox1.Text) And IsNumeric(TextBox2.Text) And IsNumeric(TextBox3.Text) Then
If Val(TextBox1.Text) < 0 Or Val(TextBox1.Text) > 100 Then
over = True
TextBox1.ForeColor = Color.Red
End If
If Val(TextBox2.Text) < 0 Or Val(TextBox2.Text) > 100 Then
over = True
TextBox2.ForeColor = Color.Red
End If
If Val(TextBox3.Text) < 0 Or Val(TextBox3.Text) > 100 Then
over = True
TextBox3.ForeColor = Color.Red
End If
If over = True Then
Label4.Text = "資料輸入錯誤,請重新輸入 0 到 100 之間"
Label4.BackColor = Color.Green
Button1.Enabled = False
Else
score = (Val(TextBox1.Text) + Val(TextBox2.Text) + Val(TextBox3.Text)) / 3
Label4.Text = score
If score < 60 Then
Label4.BackColor = Color.Red
End If
End If
Else
Label4.Text = "資料輸入錯誤,成績中有一個非數字"
Label4.BackColor = Color.Green
Button1.Enabled = False
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()
Label4.Text = ""
Label4.BackColor = Color.Empty
over = False
TextBox1.ForeColor = Color.Black
TextBox2.ForeColor = Color.Black
TextBox3.ForeColor = Color.Black
TextBox1.Focus()
Button1.Enabled = True
End Sub
End Class
這個論壇的權限:
您 無法 在這個版面回復文章