A Newbie having trouble passing variables from one sup-procedure to another 
Author Message
 A Newbie having trouble passing variables from one sup-procedure to another

Put "Option Explicit" at the top of all your modules and forms. This will
show you any variables that have not been dim'ed.

Remove your  "Dim MinValue as ..." from your sub, if you have one. And place
it at the top of the form in the "General" section as "Dim MinValue as
Integer" (Or whatever)

Quote:

>Dear Group,
>Please help me if possible.  I have created a variable called MinValue
>in a subprocedure.  When I call this variable in another sub-procedure
>it continues to give the value 0 but is working correctly within the
>sub-procedure of which it was made.  Can anyone help me to pass this
>variable correctly?  (Before I commit {*filter*} on my computer.

>Thanks in advance



Sun, 22 Apr 2001 03:00:00 GMT  
 A Newbie having trouble passing variables from one sup-procedure to another
Dear Group,
Please help me if possible.  I have created a variable called MinValue
in a subprocedure.  When I call this variable in another sub-procedure
it continues to give the value 0 but is working correctly within the
sub-procedure of which it was made.  Can anyone help me to pass this
variable correctly?  (Before I commit {*filter*} on my computer.

Thanks in advance



Mon, 23 Apr 2001 03:00:00 GMT  
 A Newbie having trouble passing variables from one sup-procedure to another
Hi, Kathy

Add new module to project and declare public variable there Public
MinValue As ...
instead of Dim MinValue As ...
Then remove declaration from subprocedure where it was before. Now you can
access this variable from everywhere in VB Project. It is possible to pass
MinValue as parameter to another procedure, but previously described way
will be easier for you

Good luck ! ! !
Ivars

Quote:

> Dear Group,
> Please help me if possible.  I have created a variable called MinValue
> in a subprocedure.  When I call this variable in another sub-procedure
> it continues to give the value 0 but is working correctly within the
> sub-procedure of which it was made.  Can anyone help me to pass this
> variable correctly?  (Before I commit {*filter*} on my computer.

> Thanks in advance



Mon, 23 Apr 2001 03:00:00 GMT  
 A Newbie having trouble passing variables from one sup-procedure to another
Hey, Kathy,
every variable is either a local or a global variable.
If you created MinValue in a subprocedure, so this variable is a
local variable for this subprocedure. You can created a variable
called MinValue also in another subprocedure, these both variables are
not the same!!!
VB is able to use variables without declaration. In this case, the
variable has the type Variant.
In your case, the use of MinValue in another subprocedure gives Zero
because the - local - variable MinValue is not set with an value.
I hope I could help you.
Good Bye.
Thomas.
Quote:

> Dear Group,
> Please help me if possible.  I have created a variable called MinValue
> in a subprocedure.  When I call this variable in another sub-procedure
> it continues to give the value 0 but is working correctly within the
> sub-procedure of which it was made.  Can anyone help me to pass this
> variable correctly?  (Before I commit {*filter*} on my computer.

> Thanks in advance



Mon, 23 Apr 2001 03:00:00 GMT  
 A Newbie having trouble passing variables from one sup-procedure to another

Kathy; you need to do two things

(1) First and foremost
Set your environment to use OPTION EXPLICT as the default.
This will tell VB to make sure that All variables are defined !!!!

What you are experiencing is a data scoping problem masked by the fact
that BASIC defines variables when it sees them if they are not aready
defined.  

As for the scope issue, you assigned MinValue a value in one
sub-routine, this varaible is now only visible to that sub-routine. When
you reference the variable in another sub-routine, BASIC creates another
local definition of the variable, that is why it is ZERO.

(2) Add a new module and define MinValue as mention below you will be
fine.  PS make sure that you take the local defeintion of MinValue out
of the sub-routine.

Option Explicit

Public MinValue as Integer

Quote:

> Hi, Kathy

> Add new module to project and declare public variable there Public
> MinValue As ...
> instead of Dim MinValue As ...
> Then remove declaration from subprocedure where it was before. Now you can
> access this variable from everywhere in VB Project. It is possible to pass
> MinValue as parameter to another procedure, but previously described way
> will be easier for you

> Good luck ! ! !
> Ivars


> Hey, Kathy,
> every variable is either a local or a global variable.
> If you created MinValue in a subprocedure, so this variable is a
> local variable for this subprocedure. You can created a variable
> called MinValue also in another subprocedure, these both variables are
> not the same!!!
> VB is able to use variables without declaration. In this case, the
> variable has the type Variant.
> In your case, the use of MinValue in another subprocedure gives Zero
> because the - local - variable MinValue is not set with an value.
> I hope I could help you.
> Good Bye.
> Thomas.


> > Dear Group,
> > Please help me if possible.  I have created a variable called MinValue
> > in a subprocedure.  When I call this variable in another sub-procedure
> > it continues to give the value 0 but is working correctly within the
> > sub-procedure of which it was made.  Can anyone help me to pass this
> > variable correctly?  (Before I commit {*filter*} on my computer.

> > Thanks in advance

  vcard.vcf
< 1K Download


Mon, 23 Apr 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Having trouble passing object to a sub procedure

2. Having trouble learning how to call stored procedures.

3. Newbie having trouble with VBA Code in Access

4. Having trouble defining global variables

5. Newbie having trouble with Object Error

6. Help -- having trouble passing a UDT as a parameter

7. Newbie Having trouble with this User Info script, Please help

8. Having trouble using findfirst with a variable

9. Pass variable from procedure to procedure

10. Crystal 8.5 - troubles with passing strings as stored procedure parameters

11. Trouble passing parameters to a stored procedure in ADO

12. passing variable from procedure to module

 

 
Powered by phpBB® Forum Software