Problem retrieving value from an array of string [Resolved]
I have this problem when retrieving value from an array of string.
this is my code:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strSplitted() As String = funSplitText(txtRinggit.Text)
MessageBox.Show(strSplitted.Length)
Dim intCounter As Integer
For intCounter = 0 To strSplitted.GetUpperBound(0)
MessageBox.Show(strSplitted(intCounter).ToString)
Next
End Sub
When Button1 is clicked, the length of strSplitted can be display correctly.
But the error oocurs inside the For...Next Statement in this line:
Code:
MessageBox.Show(strSplitted(intCounter).ToString)
The error message shows:
Quote:
An unhandled exception of type 'System.NullReferenceException' occurred in Payroll System.exe.
Additional information: Object reference not set to an instance of an object.
Why is this so? it seem to retrieve the length of the array without problem, but has problem retrieving each value inside array.
How can i overcome this problem? please guide. thank you.