|
-
Aug 20th, 2008, 07:25 PM
#1
Re: about array object variable
 Originally Posted by joaquim
 Originally Posted by MartinLiss
What type of objects are they?
in these case doesn't metter, because that function only use the position and size of objects... that every objects use the same properties...
Yes, it does matter.
Your Collision() function required an object argument, that can be any type of object but it must be an actual object (such as PictureBox, etc), it cannot be a dummy un-set object.
Your code below does not work by many reasons:
Code:
Public ObjectsName() As Object
Public NumberObjects As Long
... ...
NumberObjects = lstAddCollisionObject.ListCount
ReDim ObjectsName(NumberObjects)
For i = 0 To NumberObjects
Set ObjectsName(i).Name = lstAddCollisionObject.List(i)
Next i
In statement: Set something1 = something2
both something1 and something2 must be some kind of objects, not strings.
With 2 strings, you cannot use
Set string1 = string2
but just simply
string1 = string2
Before you can use Object1.Name, Object1 need to be Set to some actual object,
otherwise you get error message "Object Variable or With block variable not set".
So, you need to have something like this:
Code:
ReDim ObjectsName(NumberObjects)
For i = 0 To NumberObjects
Set ObjectsName(i) = myPicture(i) '-- make sure myPicture(i) already existed
ObjectsName(i).Name = lstAddCollisionObject.List(i)
'-- noted that after the above line, myPicture(i).Name will be
'-- also changed to the same as ObjectsName(i).Name
Next i
-
Aug 20th, 2008, 07:32 PM
#2
Re: about array object variable
Or as I suggested
Code:
ReDim ObjectsName(NumberObjects)
For i = 0 To NumberObjects
myPicture(i).Tag= lstAddCollisionObject.List(i)
Next i
-
Aug 21st, 2008, 07:05 AM
#3
Thread Starter
PowerPoster
Re: about array object variable
ok i resolve my problem(at least i think), but i have a little problem....
heres the code:
Code:
Public ObjectsName() As String
Public NumberObjects As Long
Private Sub UserControl_Show()
blnShow = True
ReDim ObjectsName(Extender.Parent.Controls.Count)
NumberObjects = Extender.Parent.Controls.Count - 1
For i = 0 To Extender.Parent.Controls.Count - 1
ObjectsName(i) = Extender.Parent.Controls(i).Name
MsgBox ObjectsName(i)
Next i
end sub
Private Sub PropertyPage_ApplyChanges()
NumberObjects = 0
For i = 0 To lstAddCollisionObject.ListCount - 1
If lstAddCollisionObject.Selected(i) = True Then NumberObjects = NumberObjects + 1
Next i
ReDim ObjectsName(NumberObjects)
For i = 0 To lstAddCollisionObject.ListCount - 1
If lstAddCollisionObject.Selected(i) = True Then ObjectsName(i) = lstAddCollisionObject.List(i)
Next i
For i = 0 To NumberObjects
MsgBox ObjectsName(i)
Next i
end sub
my list box is with check style activated(is why i use selected property, for see if was checked or not)
but here i have a little problem...
i recive an message box empty... can you explain to me why?
thanks
-
Aug 23rd, 2008, 12:02 PM
#4
Thread Starter
PowerPoster
Re: about array object variable
ok... resolved, thanks
Code:
Dim RealName As String
RealName = Extender.Name
For i = 0 To Extender.Container.Controls.Count - 1
If Extender.Container.Controls(i).Name <> RealName Then
If Collision(Extender, Extender.Container.Controls(i)) = True Then
RaiseEvent Collision(Extender.Container.Controls(i).Name & IFF(Extender.Container.Controls(i).TabIndex <> 0, Extender.Container.Controls(i).TabIndex, ""))
End If
End If
Next i
-
Aug 23rd, 2008, 12:04 PM
#5
Re: [RESOLVED] about array object variable
Please don't forget to pull down the Thread Tools menu and click the Mark Thread Resolved button..
-
Aug 23rd, 2008, 12:08 PM
#6
Thread Starter
PowerPoster
Re: [RESOLVED] about array object variable
 Originally Posted by MartinLiss
Please don't forget to pull down the Thread Tools menu and click the Mark Thread Resolved button..
yes i did... thanks for everything thanks...
thanks anhn... thanks for help me too...
PS: did i rate you, MartinLiss?
-
Aug 23rd, 2008, 12:11 PM
#7
Re: [RESOLVED] about array object variable
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
|