Two Instances of a Form

Posted on 2003-03-28
Medium Priority
Last Modified: 2013-11-13
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?

Question by:KS_Robert
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 32

Accepted Solution

Brendt Hess earned 2000 total points
ID: 8227921
When adding a second form to your array, you need to REDIM PRESERVE, not just REDIM:

      ReDim Preserve frmQTemps(SSTab1.Tabs)

Expert Comment

ID: 8227940
Is your Winsock control on the main form? How are you referencing it on the other forms?

Author Comment

ID: 8227987
I knew this already, but I had forgot all about it.  Thanks for the reminder!

Expert Comment

ID: 8228030
Good job, bhess1 -- I thought of that a split second after you did. Nice 2000 points! More than I made all week!

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question