| | |
value of string is cannot conerted into system.array
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2008
Posts: 3
Reputation:
Solved Threads: 0
[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
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
•
•
Join Date: Dec 2008
Posts: 3
Reputation:
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]
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]
You haven't assigned the number of elements in the second dimension of the array:
either
or later in the code
or from a variable
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 @ Windows Developer Blog
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: how to pass array of value from one calss to another class
- Next Thread: Set Byte Buffer in Ping
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account arithmetic array basic beginner bing browser button buttons center check code combobox crystalreport cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic dropdownlist excel fade file-dialog filter forms ftp generatetags hardcopy html images input insert intel internet mobile monitor ms net networking objects open output panel passingparameters pdf picturebox picturebox1 port position printing problem project save searchvb.net select serial settings shutdown soap sqlserver survey tcp temperature text textbox timer timespan toolbox transparency trim update updown user vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vba vbnet view visual visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode year





