|
-
Jul 12th, 2000, 06:58 AM
#1
Thread Starter
Hyperactive Member
Hi there,
I know how to create a control at run-time (see code below). The problem is that clicking command1 is supposed to change the caption of the label, at random, but when I click it more than once I get an error saying, 'lbl1 already exists'.
I tried the If statement below (in comments) but it didn't work. I also tried form1.refresh, but that didn't do anything either.
Any help would be appreciated.
Thanks!
Private Sub Command1_Click()
Randomize
'If lbl1.Visible = True Then GoTo Line2
Set lbl1 = Controls.Add("VB.label", "lbl1")
Line2:
With lbl1
.Left = 240
.Top = 100
.Width = 1000
.Height = 500
.Caption = Int(Rnd * 9)
.Visible = True
End With
'End If
End Sub
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
|