好吧,那麼當我選中或取消選中時,如何顯示摘要部分? 礦井因某種原因不能正常工作。我錯過了什麼嗎?我必須讓學生有能力控制信息的顯示。VB.NET如何不使用隨機生成的數字從textBoxResult的較小數中減去較大數字
公共類MathPractice
Private Sub rbAddition_CheckedChanged(sender As Object, e As EventArgs) Handles rbAddition.CheckedChanged
'Change the label to plus
lblPlus.Text = " + "
End Sub
Private Sub rbSubtraction_CheckedChanged(sender As Object, e As EventArgs) Handles rbSubtraction.CheckedChanged
'Change the label to minus
lblPlus.Text = "-"
Dim intlbl1 As Integer = Val(lbl1.Text)
Dim intlbl2 As Integer = Val(lbl2.Text)
If rbSubtraction.Checked Then
Do While intlbl1 < intlbl2
If rbGrade1.Checked Then
intlbl1 = Random.Next(1, 10)
ElseIf rbGrade2.Checked Then
intlbl1 = Random.Next(10, 99)
End If
Loop
lbl1.Text = intlbl1.ToString
End If
End Sub
Private Sub rbGrade1_CheckedChanged(sender As Object, e As EventArgs) Handles rbGrade1.CheckedChanged
Dim random As New Random()
'Get random numbers between 1 and 10.
If rbGrade1.Checked Then
lbl1.Text = random.Next(1, 10).ToString
lbl2.Text = random.Next(1, 10).ToString
End If
End Sub
Private Sub rbGrade2_CheckedChanged(sender As Object, e As EventArgs) Handles rbGrade2.CheckedChanged
Dim random As New Random()
random.Next(10, 99)
'Get random numbers between 10 and 99.
If rbGrade2.Checked Then
lbl1.Text = random.Next(10, 99).ToString
lbl2.Text = random.Next(10, 99).ToString
End If
End Sub
Private Sub btnCheckAnswer_Click(sender As Object, e As EventArgs) Handles btnCheckAnswer.Click
'Check the answer whether it is right or wrong
'Display a message box showing right or wrong
Dim intlbl1 As Integer = Val(lbl1.Text)
Dim intlbl2 As Integer = Val(lbl2.Text)
Dim intResult As Integer = Val(txtBoxResult.Text)
Dim btnCheckAnswer As String
Select Case lblPlus.Text
Case "+"
If intResult = intlbl1 + intlbl2 Then
btnCheckAnswer = "Correct."
Else
btnCheckAnswer = "Sorry. Try Again."
End If
Case "-"
If intResult = intlbl1 - intlbl2 Then
btnCheckAnswer = "Correct."
Else
btnCheckAnswer = "Sorry. Try Again."
End If
End Select
End Sub
Private Sub chkBoxDisplaySummary_CheckedChanged(sender As Object, e As EventArgs) Handles chkBoxDisplaySummary.CheckedChanged
'Display or hide information
If chkBoxDisplaySummary.Checked Then
GroupBox2.Visible = True
Else
GroupBox2.Visible = False
End If
End Sub
Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
末級
您將獲得更好的反應,如果你能展示一些代碼,你到目前爲止 –