Variablentransfer within a class module and form

Posted on 2007-07-20
Last Modified: 2010-04-30
I have got a dll project which consists of a class module (cClass) and a form (formdll) (Modal)

In class Module I have got a public subroutine:

Public sub graph(x,y,z....)

This subroutine  does some basic calculations and populates an X;Y graph on the form.

I invoke this by Calling this subroutine from the server application
Call graph(X,Y,Z...)

As a result the graph is redrawn and everything works fine.
Now my Problem.
The form (formdll) needs to be modal and after I call the subroutine graph the focus is on this form.

In order to redraw the graph in a different scale I would like to use the variables (X,Y,Z...) again but they are out of scope by now.
So in essens I need to be able to recall the subroutine graph(X,Y,Z...) from the form with the same variables as from the server application.

One way would be to make all the different variables public wityhin the class module, but I would like to avoid this.

I hope the problem is understanable?
Question by:themroc
    LVL 7

    Expert Comment

    You can create a method rescale() on the class to which you just pass in a scaling factor rather than x, y, z. The rescale method uses (private) member variables x, y, z to plot the new dimensions.

    But if you must have x, y, z values available to the form then you will need to do something like
    define a method getDimensions() that returns an array of x, y, z (or define 3 methods getX(), getY() etc.).

    - Ravs

    Author Comment

    the problem is that I can not access the variables again from the server application. So is there any way to keep the variales within the form or class module environment?
    LVL 7

    Expert Comment

    I don't get the problem - you have instantiated the class module the object is in scope within the server, isn't it? So why can't you just depend on the object to keep track of x, y, and z?

    Author Comment

    The problem was that in my dll there is a class module and a form module.
    Than variables were used in the class module and I needed to access the same variables from the form module.
    The problem is that when I tried to acces the variables with MyClass.... there was no reference from the form to the class module. So as a result I set the reference with
    Set Myclass = new class.
    When I did this the variables were lost.

    In the end I did the following which works now:
    I created annother ordinary module within my dll project. Then I transfer the variables which I need to this module. Here they are dimensioned on a module level. With this methode I am able to access the variables from the form and it works.

    But maybe you have an idea whether it is possible to retrive variables in a form within a dll from a class module?
    Otherwise I close the Question.

    Author Comment

    Dan Rollins, cause I answered the Question on my own I would like to ask for a refund
    LVL 1

    Accepted Solution

    PAQed with points refunded (250)

    EE Admin

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    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…
    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    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…

    779 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

    12 Experts available now in Live!

    Get 1:1 Help Now