|
| |||||||||
| Tags: array, parameter |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Passing arrays as parameters in Vb.Net
I have a class that contains an array and i would like to access the individual array elements in a form. I understand that VB.net does not allow the array to be public and i think i need to pass it as a parameter? What i would like is on the form, to have a button when clicked, it checks the elements against each other to see if they are different (they are integers). |
|
#2
| ||||
| ||||
| Re: Passing arrays as parameters in Vb.Net VB.NET allows array variables to be public members of a class. implement a property which wraps around the array: \\\ Private m_Names() As String Public Property Names() As String() Get Return m_Names End Get Set(ByVal Value As String()) m_Names = Value End Set End Property /// |
|
#3
| ||||
| ||||
| Re: Passing arrays as parameters in Vb.Net
Hi, I didnt understand what exactly u want, but i made u this code, hope this will help you. Code: Dim ARRAY1 As Int16() = {2, 3, 5, 6, 7}
Dim ARRAY2 As Int16() = {4, 2, 1, 3, 5}
Dim I As Int16
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Array_compare(ARRAY1, ARRAY2) Then
MsgBox("Arrays r equal")
Else
MsgBox("Arrays not equal")
End If
End Sub
Private Function Array_compare(ByVal arr1 As Int16(), ByVal arr2 As Int16()) As Boolean
For I = 0 To arr1.GetUpperBound(0)
If arr1(I) <> arr2(I) Then
Return False
'return false when it just find one item not equal
End If
Next
'returns true only if all items are equal
Return True
End Function |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Passing arrays as parameters in Vb.Net" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Arrays in C++ | Acolapissa | Software Development | 3 | 19-12-2010 10:05 AM |
| Arrays in C# | kavisg1 | Software Development | 3 | 07-10-2010 08:55 PM |
| Passing optional parameters in java | Miles Runner | Software Development | 5 | 05-03-2010 10:20 AM |
| How to use an Arrays in PHP? | Jacques25 | Software Development | 4 | 25-02-2010 01:24 AM |
| Arrays in C# | DotNetUser | Guides & Tutorials | 2 | 03-12-2008 05:31 PM |