Solved

How to declare STATIC variable in VB5?

Posted on 1998-04-29
1
217 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now