ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Retain Variant / String value (https://www.excelbanter.com/excel-programming/340007-retain-variant-string-value.html)

abc[_6_]

Retain Variant / String value
 
Dear all

I am new in vba and vb. I found that the store value of a variant or string
will change back to zero after jump to other sub or private sub. How can I
retain the store value even the program proceed to other sub or private sub?

Thanks



NickHK

Retain Variant / String value
 
abc,
You need to read up about "Scope" of variables.
Also, understand how parameters to functions/subs work.

NickHK

"abc" wrote in message
...
Dear all

I am new in vba and vb. I found that the store value of a variant or

string
will change back to zero after jump to other sub or private sub. How can I
retain the store value even the program proceed to other sub or private

sub?

Thanks





Shatin[_2_]

Retain Variant / String value
 
You can declare a static variable:

Static x as string

"abc" wrote in message
...
Dear all

I am new in vba and vb. I found that the store value of a variant or

string
will change back to zero after jump to other sub or private sub. How can I
retain the store value even the program proceed to other sub or private

sub?

Thanks





abc[_6_]

Retain Variant / String value
 
thanks to all!

"Shatin" ¦b¶l¥ó
¤¤¼¶¼g...
You can declare a static variable:

Static x as string

"abc" wrote in message
...
Dear all

I am new in vba and vb. I found that the store value of a variant or

string
will change back to zero after jump to other sub or private sub. How can

I
retain the store value even the program proceed to other sub or private

sub?

Thanks








All times are GMT +1. The time now is 03:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com