Results 1 to 4 of 4

Thread: Generating Autonumber

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2002
    Location
    Cebu, Philippines
    Posts
    24

    Generating Autonumber

    Hi everybody!
    Here i am again asking for help from you guys!

    My question is this: How do i generate autonumber in VB? Please help me...I need an answer as soon as possible. Thanks..

  2. #2
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    AutoNumber for what exactly??
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  3. #3
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    The only Autonumber i know of deals with a type of field in Access databases. And this simply is: add 1 to last record's ID value

  4. #4
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    If you have a set of numbers, all you need to do is loop through the numbers and add one to the highest number in the set.

    VB Code:
    1. ' Declarations
    2. lngArr() as long
    3.  
    4. Private Function GetNextID as Long
    5. dim i as long
    6. dim iHigh as long
    7.  
    8. For i = lbound(lngArr) to Ubound(lngArr)
    9.   if lngArr(i) > iHigh then iHigh = lngArr(i)
    10. Next i
    11.  
    12. GetNextId = iHigh +1
    13.  
    14. End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width