|
-
Mar 16th, 2004, 08:56 AM
#1
Thread Starter
Hyperactive Member
Change Array variable from other class then it's 'creator' [RESOLVED]
Hi everyone,
Another question by me !
Next problem I encounter is this one:
I create an array of an class, called Pion, like this:
VB Code:
Friend pioPion(30) As Pion
And give it it's values like this:
VB Code:
Private Sub cmdTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdTest.Click
Dim iLoop As Integer
Dim iX As Integer = 0
Dim iY As Integer = 0
For iLoop = 0 To 29
Dim testPion As New Pion(iLoop, 0, "Blue")
pioPion(iLoop) = testPion
pioPion(iLoop).SetCoordinates(iX, iY)
If iX = 9 Then
iY += 1
iX = 0
Else
iX += 1
End If
Next
End Sub
But i want this not in my frmMain Code but in a other class.... Is this possible? Hope you get what I mean... if not just ask for clarification!
Grtz,
Bloged
Last edited by Bloged; Mar 16th, 2004 at 11:08 AM.
-
Mar 16th, 2004, 09:25 AM
#2
Hi.
In your other class you could have a function like
VB Code:
Public Function LoopPion() As Pion()
Dim iLoop As Integer
Dim iX As Integer = 0
Dim iY As Integer = 0
Dim pioPion(30) as Pion
For iLoop = 0 To 29
Dim testPion As New Pion(iLoop, 0, "Blue")
pioPion(iLoop) = testPion
pioPion(iLoop).SetCoordinates(iX, iY)
If iX = 9 Then
iY += 1
iX = 0
Else
iX += 1
End If
Next
Return pioPion
End Function
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Mar 16th, 2004, 09:31 AM
#3
Thread Starter
Hyperactive Member
Thanks pax for your answer, but iIf I'm not mistaken this will create the array in my other class and not on the frmMain....
Or does this statement:
Sends back the complete array?
Grtz,
Bloged
-
Mar 16th, 2004, 09:38 AM
#4
Hi.
Yes, it will return the entire array.
Another way could be to pass the array as a ByRef variable instead.
VB Code:
Public Sub LoopPion(ByRef pioArray() as Pion)
'
'
'
End Sub
But all-in-all, you'll end up with the same result.
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Mar 16th, 2004, 09:43 AM
#5
Thread Starter
Hyperactive Member
Thanks pax... this seems like what I've been looking for... Will test it when I can!
Grtz,
Bloged
Edit: Tested and works great! Thanks Again!
Last edited by Bloged; Mar 16th, 2004 at 11:08 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|