|
-
Jul 12th, 2000, 09:30 AM
#4
Thread Starter
Hyperactive Member
Thanks,
HesaidJoe,
I commented it out but got an error saying, 'Object required'. Then I put in an error handler, like this:
Private Sub Command1_Click()
Randomize
On Error GoTo errorhandler
Set lbl1 = Controls.Add("VB.label", "lbl1")
With lbl1
.Left = 240
.Top = 100
.Width = 1000
.Height = 500
.Caption = Int(Rnd * 9)
.Visible = True
End With
End If
errorhandler:
With lbl1
.Caption = Int(Rnd * 9)
End With
End Sub
....but I still got a message saying, 'Object required'.
Megatron, thanks for your help but I already know how to create a control at run time. I think I have to use my method, rather than yours, because yours in fine if you want to create a control on a form - whereas in fact I have to create my label in a picture box already on the form.
Everytime command1 is clicked, the caption in the label will change. The problem is that I don't know how to change the label caption without creating the label all over again, and I get an error saying - 'sorry, label1 already exists'.
Any ideas?
Thanks.
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
|