Solved

control array

Posted on 1998-10-22
7
166 Views
Last Modified: 2010-04-30
Still seeking answers. This is what I've come up with so far.

Using a separate Command click:
     Sub Command1_click()
        dim d as integer
        for d = 1 to buttons
          unload imgX(d)
          buttons = buttons - 1
        next d
    end sub

  if I try to call this routine, without clicking the command button I get an error. I have also tried to immediately unload the control array element after creating it and get the same error as below.

      call routine code
           command1.setfocus
           sendkeys "%C", true

I get this error:

     unable to unload in this context

Is there a way to use a call procedure without the user actually clicking on the command button to get the control array to clear. So when a combo box selection is used the control array is recreated.

0
Comment
Question by:MaryD
  • 4
  • 3
7 Comments
 
LVL 2

Accepted Solution

by:
BergJC earned 50 total points
ID: 1441139
MaryD,
     Just place the code in your command click event into a function inside a code module. Then you can call it from wherever you want.

0
 
LVL 2

Expert Comment

by:BergJC
ID: 1441140
For example:

Inside a code module, have this:
     Sub UnloadArray()
            dim d as integer
            for d = 1 to buttons
              unload imgX(d)
              buttons = buttons - 1
            next d
      End sub

Then you can just call this sub from anywhere in your program.
0
 

Author Comment

by:MaryD
ID: 1441141
BergJC,

I tried putting this code into

1. as a function
       function UnloadArray()
       .
       end function
       received same error
2. as a sub routine in a module - ModMain.bas
       public sub UnloadArray()
       .
       end sub
       received compiler error that the control array was not
       recognized
3. the command_click still works even though nothing else does

What did you mean by code module? Any of the above?

This doesn't make any sense how the command_click works but the
others do not.!!!!


0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:BergJC
ID: 1441142
Did you put the form name in front of the control array when you were referencing them?

For instance,
     
2. as a sub routine in a module - ModMain.bas
      public Sub UnloadArray()
          dim d as integer
          for d = 1 to buttons
              unload form1.imgX(d)
              buttons = buttons - 1
          next d
       end Sub

0
 
LVL 2

Expert Comment

by:BergJC
ID: 1441143
In order to reference the control array from a module, you must also place the form name in front of the control object.
0
 

Author Comment

by:MaryD
ID: 1441144
I placed the form name in front of the imgX(d) in the module, it now recognizes the control array, but unfortunately I still get
the error: "Unable to unload in this context"

We are running VB6 if this makes a difference.
0
 

Author Comment

by:MaryD
ID: 1441145
thanks for your help
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now