Solved

How to declare STATIC variable in VB5?

Posted on 1998-04-29
1
220 Views
Last Modified: 2011-10-03
I am basically a C++ programmer. I want to declare a static variable in VB. How can I do this?
I know there is a static keyword but how can I initialize a variable that is declared as Static?
0
Comment
Question by:Moin
1 Comment
 
LVL 18

Accepted Solution

by:
deighton earned 20 total points
ID: 1434964
Slightly clumsy but worked for me

Private Sub Timer1_Timer()
    Static x As Integer
    Static bVar as boolean
    if not bVar then
       x = 100
       bVar = true
    end if
   
    etc.....

End Sub
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

773 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