|
-
Jun 20th, 2000, 10:18 PM
#1
Thread Starter
Member
Does anyone know if it is possible to create a certain number of shape objects whilst the program is running? What I want to do is create a certain number of rectangles depending on a variable in my program.
-
Jun 20th, 2000, 10:32 PM
#2
Make a CommandButton and put this code in it.
Code:
Private Sub Command1_Click()
Controls.Add "VB.Shape", "Shape1"
Me!Shape1.Move 0, 0
Me!Shape1.Visible = True
End Sub
-
Jun 20th, 2000, 11:31 PM
#3
Thread Starter
Member
That didn't work, I get an error saying "Object doesn't support that property or method". Does that work for you cos I am using VB5 SP3 aswell?
-
Jun 20th, 2000, 11:39 PM
#4
transcendental analytic
Yeah, that's the big deal with vb6, i have vb5 and that doesn't work for me either. You must use a an array of objects and use Load object(index) to load a second item. There's a lot of threads on this topic, go search for "create runtime"
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 21st, 2000, 12:29 AM
#5
New Member
In VB6 I believe you would go about this using a control array. Try it in VB5 and see if this works.
Your form has a control Shape1. In the IDE, set it's Index property to 0. This tells VB it is the first member in a control array.
Code:
Dim intNumber as Integer
'intNumber can be any integer value
intNumber = 6
'Enter your loop
For i = 1 To intNumber
'Load a new instance of Shape1 into the control array
Load Shape1(i)
'The default setting of each new controls Visible
'property is False. Change it or you won't see them
Shape1(i).Visible = True
'Remember not to overlap them unless you want to
'This spaces the controls out vertically with 20 twips or
'or pixels whatever between them. You can do the same
'vertically by using Top instead of Left
Shape1(i).Left = Shape1(i - 1).Left + Shape1(i).Width + 20
Next
I hope this helps But as I said this something I've done in VB6, I don't recall if VB5 would do the same thing in the same fashion. Give it a shot.
-
Jun 21st, 2000, 04:13 PM
#6
Thread Starter
Member
Thanks
Cheers very much for that, it does work in VB5.
-
Jul 14th, 2000, 03:09 AM
#7
Lively Member
This should work:
Code:
Dim Kontroll As Control
Dim ActiveForm As Object
Set ActiveForm = Form1
Set Kontroll = ActiveForm.Controls.Add("Forms.TextBox.1", "SomeNameOnTheControl)
Kontroll.left = 10
Kontroll.top = 10
Kontroll.width = 100
Kontroll.height = 16
Kontroll.Text = "SomeText"
etc...
Done this is VBA for Office 97 which is somewhere between VB 4 and VB 5.
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
|