Solved

Setting a starting point for counter

Posted on 2000-03-29
3
151 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

895 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

17 Experts available now in Live!

Get 1:1 Help Now