Question:

Why won't OOo Basic remember my static variable value?

by  |  earlier

0 LIKES UnLike

Here's my code:

Sub PleaseRemembermyVariable

Static Test as integer

Test = Test + 1

Print Test

End Sub

Every time I run this procedure the variable 'test' is reset to 0. I've been following a tutorial but it won't work for me ;(

Thanks

 Tags:

   Report

2 ANSWERS


  1. I believe the static variable must be declared as a class variable and not a local variable within the method because everytime that method is run it will reset the static variable as you declare it over and over.


  2. You have to put the static variable at the class scope

    You can have static variables at the local scope in c++, but not in VB.

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions