Solved

Setting a starting point for counter

Posted on 2000-03-29
3
154 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

734 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