dataGridViewに質問(txtQuestion.Text)を追加できませんが、同じ質問を追加するとMessageBox.Show( "同じ質問を入力することはできません")が表示されます。データの追加は私の唯一の問題です。VB.NET nullReferenceException未処理
Dim qID As String
rnd.Next(0, 99999)
For Each row As DataGridViewRow In UsersDBDataGridView.Rows
If txtQuestion.Text = row.Cells(1).Value.ToString Then '<-- NullReferenceException was unahandled.
MessageBox.Show("You cant enter the same Question.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
valid = True
Exit For
Else
valid = False
End If
Next
If cbxDifficulty.Text = "Easy" Then
diff = "E"
diffValue = 5
ElseIf cbxDifficulty.Text = "Average" Then
diff = "A"
diffValue = 10
ElseIf cbxDifficulty.Text = "Difficult" Then
diff = "D"
diffValue = 20
End If
qID = diff & "-" & Date.Now.Date.ToString("ddMMMyyyy").ToUpper & "-" & rnd.ToString("00000")
If valid = False Then
Me.UsersDBTableAdapter.Add(qID, txtQuestion.Text, txtAnswer.Text, diffValue)
Me.UsersDBTableAdapter.Fill(Me.UsersDBDataSet.UsersDB)
End If
[NullReferenceExceptionとは何か、それを修正する方法は?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i) -fix-it) – Enigmativity
あなたの問題を解決した回答には、了承してください。 –