value of string type cannot be converted to system.array

shobiat

New member
Joined
Dec 14, 2008
Messages
2
Programming Experience
Beginner
hi..i m new to vb.net..
can u help for this error
VB.NET:
Public Class Form1
    Dim m, n, i, j As Integer
    Dim arr(20) As array1

    Structure array1
        Public a()() As Array
    End Structure

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Button1.Enabled = True
        Button2.Enabled = True
        Button3.Enabled = True
        Button4.Enabled = True
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        m = InputBox("Number of Employee")
        n = InputBox("Number of Product")
        j = 0
        For i = 1 To m - 1 Step 1
'// error in this line as value of string type cannot be converted to system.array
            arr(j).a(i)(0) = Val(TextBox1.Text)
            'MessageBox.Show(arr(j).a(i)(0))
        Next i
    End Sub
End Class
 
error in this line as Object reference not set to an instance of an object.

hi..
i m new to vb.net..
can u help for this erroe
VB.NET:
Public Class Form1
    Dim m, n, i, j As Integer
    Dim a(20)() As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Button1.Enabled = True
        Button2.Enabled = True
        Button3.Enabled = True
        Button4.Enabled = True
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        m = InputBox("Number of Employee")
        n = InputBox("Number of Product")

        For i = 1 To m - 1 Step 1
            '' error in this line as Object reference not set to an instance of an object.
            a(i)(0) = InputBox("ENTER")
            MessageBox.Show(a(i)(0))


        Next i
    End Sub
End Class
 
I am also a vb.net forum newbie...but I might be able to give you a few pointers.

In the first example your entire structure needs to be above public class form1. Also, in the second example you probably need something like 'Dim a(20)(0) As Integer'. I can't guarentee this will help you, but I would say try those and report back if that helps or not.
 
Back
Top