Solved

Setting a starting point for counter

Posted on 2000-03-29
3
153 Views
Last Modified: 2010-05-02
I am utilising a counter that can be called from various points in a project.

The routine is in a module and evertime it is called the integer increments by one. However I need the counter to start from 99004500 therefore how do I set this as the initial integer value.
0
Comment
Question by:Mister_Simon
3 Comments
 
LVL 1

Accepted Solution

by:
eab111098 earned 15 total points
ID: 2666601
use a sub main() subroutine as your startup. goto project->properties and set your start up for the project to sub main(). then in a module, create a subroutine called "public sub main()". in the main() subroutine, set your counter to whatever value you desire and then do a form.load event on your startup form. this will initialize the counter to your desired value and load up the initial form you want.

Ed.
0
 
LVL 3

Expert Comment

by:carruina
ID: 2666705
You can define a Const with the value that you want

In the next code every time you click the Command Button you can see the secuencie
 99004501 , 99004502 , ...


Const INIT_VALUE = 99004500

Private Sub Command1_Click()
Dim result As Long
MsgBox INIT_VALUE + counter()
End Sub

Public Function counter() As Integer
Static aux As Integer

aux = aux + 1
counter = aux
End Function


0
 

Author Comment

by:Mister_Simon
ID: 2668542
Works Ed !!

although had to use a form.SHOW in the module rather than form.LOAD as that did not work.

Do you think this will cause any problems ????
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

809 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