Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

control array

Posted on 1998-10-22
7
Medium Priority
?
171 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
[X]
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
  • 4
  • 3
7 Comments
 
LVL 2

Accepted Solution

by:
BergJC earned 200 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Suggested Courses

688 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