| | |
Passing arrays between subs
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2005
Posts: 2
Reputation:
Solved Threads: 0
just like any other variable.
declare them in the first sub or global, on reference to the second sub put them between brackets, like this:
'Global declaration, variables can be used in entire script.
Dim strArray(1, 10) as String
Private Sub First()
'Local declaration, used in only this sub or referred to when calling subs.
Dim intArray(1, 10) as Integer
Second(intArray)
'or
Second()
End Sub
Private Sub Second(intArray)
strArray(1) = "A"
intArray(1) = 2
End Sub
declare them in the first sub or global, on reference to the second sub put them between brackets, like this:
'Global declaration, variables can be used in entire script.
Dim strArray(1, 10) as String
Private Sub First()
'Local declaration, used in only this sub or referred to when calling subs.
Dim intArray(1, 10) as Integer
Second(intArray)
'or
Second()
End Sub
Private Sub Second(intArray)
strArray(1) = "A"
intArray(1) = 2
End Sub
•
•
Join Date: Dec 2002
Posts: 461
Reputation:
Solved Threads: 56
Try something like this:
I didn't do it but check when passing arrays that your index is not outside the bounds of the array.
VB.NET Syntax (Toggle Plain Text)
Dim myArray(10) As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click AddArray(myArray, Integer.Parse(TextBox2.Text)) TextBox1.Text = myArray(Integer.Parse(TextBox2.Text)).ToString End Sub Private Sub AddArray(ByVal thisArray As Array, ByVal Index As Integer) thisArray(Index) = Index + 3 End Sub
Wayne
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
![]() |
Similar Threads
- Help: Passing arrays between functions (C)
- What relation does **indirection operator have with Multidimensional Arrays (C++)
- Passing Arrays of Objects to Member Functions (C++)
- Passing arrays of objects to functions (C++)
- passing arrays to classes? (Java)
- passing arrays in visual basic (Visual Basic 4 / 5 / 6)
Other Threads in the VB.NET Forum
- Previous Thread: crystal report layout
- Next Thread: register page using SQL server
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2008 access add advanced application array assignment basic binary box button buttons center click code combo connectionstring convert cpu data database databasesearch datagrid datagridview design designer dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists firewall folder forms image images isnumericfuntioncall listview login map math memory mobile module msaccess mssqlbackend mysql navigate net number opacity pan peertopeervideostreaming picturebox picturebox2 port print printpreview record regex reports" reuse right-to-left save savedialog search serial socket sqldatbase sqlserver storedprocedure string temp textbox timer txttoxmlconverter useraccounts usercontol usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web wpf xml





