I have a program that I would like to be able to create a bunch of boxes from a set of coordinates from an outside file. Is there any way to have the program create a new box on its own, or do they have to all be made before the program starts?
Printable View
I have a program that I would like to be able to create a bunch of boxes from a set of coordinates from an outside file. Is there any way to have the program create a new box on its own, or do they have to all be made before the program starts?
look here, just replace "VB.CommandButton" with "VB.Shape"
http://forums.vb-world.net/showthrea...threadid=40271
Cool, Thanks.
I haven't tested this at all, just wrote it and there still to write if you want to write the file, the data is stored binary...
Code:'this dynamic array will contain the shapes created in runtime
'no need to mess with withevents since shapes don't have events.
Private shapes() As shape
'this is for the the stored properties of the shapes
Private Type tshape
top As Integer
left As Integer
width As Integer
height As Integer
End Type
'this will open a file, read the amount of shapes, and then read the array of tshapes
Dim count&, tshape() As tshape, x&
Open file For Binary As #1
Get #1, , count
ReDim tshape(count - 1)
Get #1, , tshape
Close
For x = 0 To count - 1
'this will create the shape and put it in shapes array
Set shapes(x) = Controls.Add("VB.Shape", "Shape" & x)
With tshape(x)'then just set the properties up...
shapes(x).left = .left
shapes(x).top = .top
shapes(x).width = .width
shapes(x).height = .height
shapes(x).shape = 0
shapes(x).Visible = True
End With
Next x