|
-
Dec 7th, 2002, 03:34 PM
#1
Thread Starter
Frenzied Member
Create Control (Runtime)
I know it must be possible; How do i create a control (for instance a imagebox) at runtime? Lets say i want to have a person enter a number between the number 1 and 100 and when they click a button it creates that many controls. How do i accomplish this?
- JayWare
Live to love. Not to Hate
Im to busy to have a site. But I got one and still working on it.
http://dre3k.net/
-
Dec 7th, 2002, 03:37 PM
#2
VB Code:
Dim i As Integer, x As Integer
Dim img As Image
i = 10
For x = 1 To i
Set img = Controls.Add("VB.Image","Image" & x)
img.Move (x*10),0
img.Visible = True
Next
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Dec 7th, 2002, 03:47 PM
#3
Fanatic Member
Originally posted by crptcblade
VB Code:
Dim i As Integer, x As Integer
Dim img As Image
i = 10
For x = 1 To i
Set img = Controls.Add("VB.Image","Image" & x)
img.Move (x*10),0
img.Visible = True
Next
Is this code in a Form?
-
Dec 7th, 2002, 03:55 PM
#4
Thread Starter
Frenzied Member
this code has some bugs or something , im not saying you did it but like when i press play (i changes it to command button) when i press play i shows the buttons too close and some too far
- JayWare
Live to love. Not to Hate
Im to busy to have a site. But I got one and still working on it.
http://dre3k.net/
-
Dec 7th, 2002, 04:06 PM
#5
Thread Starter
Frenzied Member
OK i did some work and decided to use a timer instead but your code was the core of it here is the final
VB Code:
Public i As Integer, x As Integer, y As Integer, w As Integer
Private Sub Form_Load()
y = 0
w = 0
End Sub
Private Sub Timer1_Timer()
Dim CMD As CommandButton
i = 10
y = y + 1
x = y
If x = 10 Then
Timer1.Enabled = False
Else
Set CMD = Controls.Add("VB.CommandButton", "Command" & x)
CMD.Width = 500
CMD.Left = w + CMD.Width + 20
'CMD.Move (x * 100), 0
CMD.Visible = True
LImg = CMD.Left
w = CMD.Left
End If
End Sub
- JayWare
Live to love. Not to Hate
Im to busy to have a site. But I got one and still working on it.
http://dre3k.net/
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
|