I'm studying chemistry and wanted to make a quick app for studying the periodic table.
What I have is 36 text boxes. I have a structure that can hold each of the 36 element's info, and an array with 36 instances of the structure.
Example:
I want to run the app, and then fill in each text box with the appropriate info, I want the text boxes correctly filled in to turn green, and more importantly the incorrect ones to turn blue.
(A) I get this error, (SOMTIMES ARRG!)
Null Reference Exception Was Unhandled
I have no clue why I'm getting this error sometimes, I'm referencing the box from my form
Here's my logic code
note when I mess with it, sometime the text boxes will fill in, but randomly and the comparison between the input text and the info stored in the data structure never compare correctly. 90% of the time the structure data is showing a null. It's all driving me nuts.
I about to scrap this simple project, as I'm spending more time making a study aid then actually studying.
What I have is 36 text boxes. I have a structure that can hold each of the 36 element's info, and an array with 36 instances of the structure.
Example:
VB.NET:
Dim Elements(37) As Element
Structure Element
Dim strSymbol As String
Dim strElementName As String
Dim strNumber As String
Dim strSymbolAnswer As String
Dim box As TextBox
End Structure
Elements(1).strNumber = "1"
Elements(1).strSymbol = "H"
Elements(1).strElementName = "Hydrogen"
Elements(1).strSymbolAnswer = Me.txtH.Text
Elements(1).box = Me.txtH
I want to run the app, and then fill in each text box with the appropriate info, I want the text boxes correctly filled in to turn green, and more importantly the incorrect ones to turn blue.
(A) I get this error, (SOMTIMES ARRG!)
Null Reference Exception Was Unhandled
I have no clue why I'm getting this error sometimes, I'm referencing the box from my form
Here's my logic code
VB.NET:
Dim getResults(1) As String
Dim i As Integer = 1
While i < 37
If Elements(i).strSymbolAnswer = Elements(1).strSymbol Then
i = i + 1
ReDim Preserve getResults(i + 1)
Elements(i).box.BackColor = Color.CadetBlue
Else
getResults(i) = Elements(i).strSymbolAnswer
Elements(i).box.BackColor = Color.Chartreuse
ReDim Preserve getResults(i + 1)
i = i + 1
End If
End While
End Sub
note when I mess with it, sometime the text boxes will fill in, but randomly and the comparison between the input text and the info stored in the data structure never compare correctly. 90% of the time the structure data is showing a null. It's all driving me nuts.
I about to scrap this simple project, as I'm spending more time making a study aid then actually studying.
Last edited: