Solved

control array

Posted on 1998-10-22
7
169 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 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

737 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