Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default 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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
String to Variant incorrect conversion Paul Excel Worksheet Functions 1 October 4th 07 01:11 AM
Variant as matrix curious Excel Programming 5 June 2nd 04 04:18 PM
Variant Array Steph[_3_] Excel Programming 1 June 2nd 04 01:29 AM
Variant Array with String Values - Type Mismatch jamiee Excel Programming 2 March 7th 04 03:39 AM
Variant to String Chip Pearson Excel Programming 1 September 3rd 03 03:10 PM


All times are GMT +1. The time now is 05:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"