Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

Two Instances of a Form

Here's my code:


Public frmQTemps() As QTemps

Code in my Main Form:

        ReDim frmQTemps(SSTab1.Tabs)
        Set frmQTemps(SSTab1.Tab) = New QTemps
        Load frmQTemps(SSTab1.Tab)
        frmQTemps(SSTab1.Tab).Tag = CStr(SSTab1.Tab)
        frmQTemps(SSTab1.Tab).Caption = "Temperature for Q" & qsntxt(SSTab1.Tab).Text

I have this form QTemps that I will be loading several instances of.  Now, I want to be able to tie each instance to a specific tab on my main form.  Now, this method let's me do that to a certain extent.  Once I have two tabs and load two instances of this form and start them both processing my task, I get stopped.  My winsock control array for each tab complains with:
Run-Time Error 91.  Object variable or With block variable not set.

This is at a point where i'm referencing an object on the QTemps forms that I have loaded.  But it only seems to happen when I get them both processing at the same time.  Any ideas, thoughts?

  • 2
1 Solution
Brendt HessSenior DBACommented:
When adding a second form to your array, you need to REDIM PRESERVE, not just REDIM:

      ReDim Preserve frmQTemps(SSTab1.Tabs)
Is your Winsock control on the main form? How are you referencing it on the other forms?
KS_RobertAuthor Commented:
I knew this already, but I had forgot all about it.  Thanks for the reminder!
Good job, bhess1 -- I thought of that a split second after you did. Nice 2000 points! More than I made all week!

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now