Reputation: 585
I am not sure what is wrong with this part of the program. Every time I run it there is an error message saying:
Object reference not set to an instance of an object
On the line cc.RawDataString.IndexOf("B")
.
Code:
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim cc As New CreditCard
Dim posB, posC1, posC2, posBlackSlash As Integer
posB = cc.RawDataString.IndexOf("B")
posC1 = cc.RawDataString.IndexOf("^")
posC2 = cc.RawDataString.IndexOf("^", posC1 + 1)
posBlackSlash = cc.RawDataString.IndexOf("/")
cc.RawDataString = txtRawData.Text
lblCCNumber.Text = cc.Number
lblCCNumber.Text = cc.RawDataString.Substring(posB + 1, posC1 - posB - 1)
lblLname.Text = cc.RawDataString.Substring(posC1 + 1, posBlackSlash - (posC1 + 1))
lblFName.Text = cc.RawDataString.Substring(posBlackSlash + 1, posC2 - (posBlackSlash + 1))
lblYear.Text = cc.RawDataString.Substring(posC2 + 1, 2)
lblMonth.Text = cc.RawDataString.Substring(posC2 + 3, 2)
End Sub
Upvotes: 0
Views: 2242
Reputation: 12266
It looks like you reference cc.RawDataString
before you set it to something.
Upvotes: 3