Solved

control array

Posted on 1998-10-22
7
165 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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.
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…
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…

747 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

11 Experts available now in Live!

Get 1:1 Help Now