2017-05-12 2 views
0

그래서 변수를 넣었으므로 i = 3이라고 말했지만 질문과 함께 진행되지 않으며 실제로 무엇을해야할지 모르겠습니다. 나는 올라간다. 그러나 질문은하지 않는다. .. 나는 내가 이것에서 매우 나빠질지도 모른다라는 것을 알고있다. 그러나 그것이 5 초 전에 그것이 일했던 지금까지 이유는 지금, 그렇지 않다.변수가 올라 가지 않는 이유

Public Class Test1 
Dim question(3, 5) As String 
Dim i As Integer = 2 
Dim correctanswear = 0 
Dim a As Integer = 0 
Private Sub Test1_Load() 
    question(1, 0) = "2+2=" 
    question(1, 1) = "1" 
    question(1, 2) = "2" 
    question(1, 3) = "3" 
    question(1, 4) = "4" 
    question(2, 0) = "How old are you?" 
    question(2, 1) = "12" 
    question(2, 2) = "13" 
    question(2, 3) = "18" 
    question(2, 4) = "17" 
    question(3, 0) = "7+14=" 
    question(3, 1) = "23" 
    question(3, 2) = "21" 
    question(3, 3) = "34" 
    question(3, 4) = "22" 
    Label1.Text = question(i - 1, 0) 
    nr1.Text = question(i - 1, 1) 
    nr2.Text = question(i - 1, 2) 
    nr3.Text = question(i - 1, 3) 
    nr4.Text = question(i - 1, 4) 

End Sub 

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click 
    Test1_Load() 
    Button5.Hide() 
    Button2.Visible = "True" 
End Sub 

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 
    Hide() 
    MainMenu.Show() 

End Sub 

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click 
    If a > 3 Then 
     MessageBox.Show("You answered " + correctanswear.ToString() + " questions correctly.") 
    Else 
     If i = 2 AndAlso nr4.Checked = True Then 
      correctanswear += 1 
      MessageBox.Show("You answered " + correctanswear.ToString() + " questions correctly.") 
      i = i + 1 
      MessageBox.Show(i) 
     ElseIf i = 3 AndAlso nr3.Checked Then 
      correctanswear += 1 
      MessageBox.Show("You answered " + correctanswear.ToString() + " questions correctly.") 
      i = i + 1 
      MessageBox.Show(i) 
     End If 
     If i = 4 AndAlso nr2.Checked = True Then 
      MessageBox.Show(i) 
      correctanswear += 1 
      MessageBox.Show("You answered " + correctanswear.ToString() + " questions correctly.") 
      Button2.Hide() 
      Button5.Text = "Retake the test" 
      Button5.Show() 

     End If 
    End If 
    a = a + 1 

End Sub 

최종 클래스 사용자가 그렇게 Test1_Load를 호출 질문 업데이트 있음을해야 정답을 입력 할 때마다

+0

레이블에 표시되는 내용과 대신 표시되는 내용을 설명하십시오. – Steve

+0

은 2 + 2 =라는 질문으로 남아 있습니다. 그래도 메시지 상자에 i = 3이 표시되고 질문이 변경되어야하며 거기에 붙어 있습니다. – Axel8017

답변

1

.

예 : 다른 주에

If i = 2 AndAlso nr4.Checked = True Then 
    correctanswear += 1 
    MessageBox.Show("You answered " + correctanswear.ToString() + " questions correctly.") 
    i = i + 1 
    MessageBox.Show(i) 
    Test1_Load() 
ElseIf i = 3 AndAlso nr3.Checked Then 
    correctanswear += 1 
    MessageBox.Show("You answered " + correctanswear.ToString() + " questions correctly.") 
    i = i + 1 
    MessageBox.Show(i) 
    Test1_Load() 
End If 

, 그것은 아마도 밖으로 자신의 기능에 문제 업데이트 코드를 깨는 가치가있을 것입니다 ( Test1_Load에 의해 호출하고 사용자가 올바른 답을 얻을 때) 그래서 당신은하지 않습니다 테스트 당 여러 번 질문 배열을 다시 초기화해야합니다.

관련 문제