私のスコアカウンターに問題はありません。msgboxがポップアップすると、受け取ったスコアは表示されず、ちょうど "0"になります。私はプログラムカウンターの使い方の答えを教えてくれる他のさまざまな質問を見てきましたが、その解決策は私にとってはうまくいかないようです。ラジオボタンを使用したカウンターの選択肢のクイズ
Dim grade1, percentage1 As String
Dim score1 As Integer
^^ declorations
score1 = "0"
If RadioButton1.Checked = True Then
score1 = score1 + 1
ElseIf RadioButton2.Checked = True Then
score1 = score1 + 0
End If
If RadioButton4.Checked = True Then
score1 = score1 + 1
ElseIf RadioButton3.Checked = True Then
score1 = score1 + 0
End If
If RadioButton5.Checked = True Then
score1 = score1 + 1
ElseIf RadioButton6.Checked = True Then
score1 = score1 + 0
End If
If RadioButton8.Checked = True Then
score1 = score1 + 1
ElseIf RadioButton7.Checked = True Then
score1 = score1 + 0
End If
If RadioButton9.Checked = True Then
score1 = score1 + 1
ElseIf RadioButton10.Checked = True Then
score1 = score1 + 0
End If
Select Case score1
Case 1
score1 = 0
grade1 = "U" & percentage1 = "0%"
Case 2
score1 = 1
grade1 = "D" & percentage1 = "20%"
Case 3
score1 = 2
grade1 = "C" & percentage1 = "40%"
Case 4
score1 = 3
grade1 = "B" & percentage1 = "60%"
Case 5
score1 = 4
grade1 = "A" & percentage1 = "80%"
Case 6
score1 = 5
grade1 = "A*" & percentage1 = "100%"
End Select
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MsgBox("Your score is" + score1.ToString, MsgBoxStyle.Information)
MsgBox("Your grade is" + grade1, MsgBoxStyle.Information)
MsgBox("Your percentage is" + percentage1, MsgBoxStyle.Information)
End Sub
あなたは、ファイルの先頭に 'オプション厳格on'のを追加する必要があります。 '' 0 ''は整数ではありません。その後、ブレークポイントを設定し、コードをデバッグします。また[ask]を読んで[tour]を取る。システムはおそらくあなたが投稿できる頻度を制限することに近づいています – Plutonix
そのコードを実行しているイベントは何ですか?デバッガを使用します。 'score1 = score1 + 0'ですね? – LarsTech
簡単なアドバイス: 'score1 = score1 + 0'のようなものは避けてください。コードが長くなるだけです。 'score1 = score1 + 1'は' score1 + = 1'と書くことができますが、これは短く、多くの言語でできる優れた方法です。 'RadioButton8.Checked = True Then Then'は' If RadioButton8.Checked Then'と書かれていなければなりません。これはブール値の意味です。最後に、同様のデータセットを操作するときに、多くの 'if - then'や' select'ステートメントの代わりにListsやDictionariesを使うようにしてください。 – Bob