Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Erg.. This is a really simple question, but I can't remember how to do this correctly:
I am trying to create multiple copies of the same form (not MDI, just regular forms), and then alter properties of the form and objects on the form. To get started, I tried this code, with "frmMain" and "frmNew" created:
(In a module:)
Public FormCount As Integer
Public NewForms() As frmNew(In "frmMain":)
Private Sub Command1_Click()
NewForms(Int(Text1.Text)).Caption = "New Text"
End SubPrivate Sub Command2_Click()
FormCount = FormCount + 1
ReDim NewForms(FormCount - 1)
Set NewForms(FormCount - 1) = New frmNew
NewForms(FormCount - 1).Show
End Sub
This is not the final code, all it's supposed to do it change the caption of one of the forms to make sure it is working properly. However, when I click Command2 to make a few news forms, and then click Command1 to change the caption of one of them (Text1.Text = 0), it returns Error 91: Object variable or With block variable not set.I know I am probably doing something really simple incorrectly, but I can't remember how to do this the right way (haven't done in a long, long time).
Thanks.
-Burbble

Nevermind, I think I've figured it out. I changed it to this:
(In a module:)
Public FormCount As Integer(In "frmMain":)
Dim NewForms() As New frmNewPrivate Sub Command1_Click()
NewForms(Int(Text1.Text)).Caption = "New Text"
End SubPrivate Sub Command2_Click()
FormCount = FormCount + 1
ReDim NewForms(1 to FormCount)
NewForms(FormCount).Show
End Sub
-Burbble

![]() |
VB common factor
|
ip tracer for net send?
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |