value of string is cannot conerted into system.array

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2008
Posts: 3
Reputation: shobiat is an unknown quantity at this point 
Solved Threads: 0
shobiat shobiat is offline Offline
Newbie Poster

value of string type cannot be coverted into system.array

 
0
  #1
Dec 14th, 2008
[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
Last edited by shobiat; Dec 14th, 2008 at 11:15 am. Reason: spell
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 3
Reputation: shobiat is an unknown quantity at this point 
Solved Threads: 0
shobiat shobiat is offline Offline
Newbie Poster

error in this line as Object reference not set to an instance of an object.

 
0
  #2
Dec 14th, 2008
[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]
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: value of string is cannot conerted into system.array

 
0
  #3
Dec 15th, 2008
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)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC