954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

value of string is cannot conerted into system.array

[code=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

shobiat
Newbie Poster
3 posts since Dec 2008
Reputation Points: 10
Solved Threads: 0
 

[code=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
[code]

shobiat
Newbie Poster
3 posts since Dec 2008
Reputation Points: 10
Solved Threads: 0
 

You haven't assigned the number of elements in the second dimension of the array:
Dim a(20)() As Integer

either Dim a(20)(10) As Integer ' For example 10

or later in the code ReDim a(20)(10)

or from a variable ReDim a(20)(SomeVariable)

Teme64
Veteran Poster
1,031 posts since Aug 2008
Reputation Points: 218
Solved Threads: 203
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You