要用就少在那機掰
Would you like to react to this message? Create an account in a few clicks or log in to continue.

成績 2010 . 9 .27

向下

成績 2010 . 9 .27 Empty 成績 2010 . 9 .27

發表  stty0910 周一 9月 27, 2010 9:50 am

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

stty0910
終極管理員
終極管理員

文章數 : 68
注冊日期 : 2010-08-06
年齡 : 30
來自 : 地球某個角落

https://bear.666forum.com

回頂端 向下

回頂端


 
這個論壇的權限:
無法 在這個版面回復文章