2016-11-26 5 views
-1

私はプログラミングで合計noobが必要ですが、私は本当に助けが必要です とにかく私は学校で10問の質問をしなければなりません。コードvga wfaで採点できません

パブリック・クラスのForm1

Dim score As Integer = 0 
Dim varname As String 


Private Sub cmdsubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsubmit.Click 
    varname = txtname.Text 
    If txtbox1.Text = 18 Then 
     score = score + 1 
    End If 
    If txtbox1.Text <= 18 Then 
     score = score - 1 
    End If 
    If txtbox1.Text >= 18 Then 
     score = score + 0 
    End If 
    If txtbox2.Text = 10 Then 
     score = score + 1 
    End If 
    If txtbox2.Text <= 10 Then 
     score = score + 0 
    End If 
    If txtbox2.Text >= 10 Then 
     score = score + 0 
    End If 
    If rb11.Checked = True Then 
     score = score + 1 
    End If 
    If rb2q3.Checked = True Then 
     score = score + 0 
    End If 
    If cmboxq4.Text = "windows xp" Then 
     score = score + 1 
    End If 
    If rbq5.Checked = True Then 
     score = score + 1 
    End If 
    If score = 0 Then 
     MsgBox("you have scored 0 out of 10" & varname) 
    End If 
    If score = 1 Then 
     MsgBox("you have scored 1 out of 10 " & varname) 
    End If 
    If score = 2 Then 
     MsgBox("you have scored 2 out of 10" & varname) 
    End If 
    If score = 3 Then 
     MsgBox("you have scored 3 out of 10" & varname) 
    End If 
    If score = 4 Then 
     MsgBox("you have scored 4 out of 10" & varname) 
    End If 
    If score = 5 Then 
     MsgBox("you have scored 5 out of 10" & varname) 
    End If 
    If score = 6 Then 
     MsgBox("you have scored 6 out of 10" & varname) 
     If score = 7 Then 
      MsgBox("you have scored 7 out of 10" & varname) 
      If score = 8 Then 
       MsgBox("you have scored 8 out of 10" & varname) 
       If score = 9 Then 
        MsgBox("you have scored 9 out of 10" & varname) 

       End If 
      End If 
     End If 
    End If 

End Sub 

エンドクラス

+0

あなたのコードファイルの先頭に 'Option Strict On'を置くべきです。 – Plutonix

答えて

0

あなたの比較は(少なくとも最初は)無意味です。

あなたは値が18の最初の2つの比較が無視されている場合、あなたは正確に何を知らない10

と比較するため、エラーを繰り返し= 18、< = 18、> = 18

を行きますあなたはそうしたいと思っています = 18、< 18、> 18

+0

私はちょうどそれらをromoveしていただきありがとうございます:) –

0

は、このコードで "もしスコア" たstatmentsを交換してみてください。

Select Case score 
      Case 0 
       MsgBox("you have scored 0 out of 10" & varname) 
      Case 1 
       MsgBox("you have scored 1 out of 10" & varname) 
      Case 2 
       MsgBox("you have scored 2 out of 10" & varname) 
      Case 3 
       MsgBox("you have scored 3 out of 10" & varname) 
      Case 4 
       MsgBox("you have scored 4 out of 10" & varname) 
      Case 5 
       MsgBox("you have scored 5 out of 10" & varname) 
      Case 6 
       MsgBox("you have scored 6 out of 10" & varname) 
      Case 7 
       MsgBox("you have scored 7 out of 10" & varname) 
      Case 8 
       MsgBox("you have scored 8 out of 10" & varname) 
      Case 9 
       MsgBox("you have scored 9 out of 10" & varname) 
      Case 10 
       MsgBox("you have scored 10 out of 10" & varname) 
     End Select 
+0

あなたはおそらくする必要があります: MsgBox( "スコアリングしました"&score.ToString()& "out of 10"&varname) – marcan2020

関連する問題