Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Unique ID Generator

Unique ID Generator

Scheduled Pinned Locked Moved Visual Basic
databasesql-serversysadmintutorial
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mcgann
    wrote on last edited by
    #1

    Hello I have been trying to development a id generator but don't know exactly how to do it. The id must have an abbreviation + year(05) + id ie. refernce=abbrev+05+id. If anyone can give some advice on this it is much appreciated. Also if it helps the abbrev comes from a database on sql server. Thank You Paul Mc Gann gfhg

    L R H 3 Replies Last reply
    0
    • M mcgann

      Hello I have been trying to development a id generator but don't know exactly how to do it. The id must have an abbreviation + year(05) + id ie. refernce=abbrev+05+id. If anyone can give some advice on this it is much appreciated. Also if it helps the abbrev comes from a database on sql server. Thank You Paul Mc Gann gfhg

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I'm not exactly clear on what you mean by "id" generator. You're using "id" to refer to the entire reference (abbrev+05+id) and as the last part of the reference. Are you asking how to concatenate abbrev, 05 and id? Or how to generate a unique string to tag onto the end of the reference? Or what? Do or not do. There is no try.

      1 Reply Last reply
      0
      • M mcgann

        Hello I have been trying to development a id generator but don't know exactly how to do it. The id must have an abbreviation + year(05) + id ie. refernce=abbrev+05+id. If anyone can give some advice on this it is much appreciated. Also if it helps the abbrev comes from a database on sql server. Thank You Paul Mc Gann gfhg

        R Offline
        R Offline
        Roy Heil
        wrote on last edited by
        #3

        How about making an idGen table, with an auto_increment column in it: Create table idGen (GenID int not null auto_increment, Abbrev varchar(3), Year char(2)) Then, when you need a new Unique ID, insert into this table and retrieve the id inserted: Insert into idGen (Abbrev, Year) values ('AA', '05') select Abbrev + Year + ltrim(str(GenID)) where GenID = @@identity Roy.

        1 Reply Last reply
        0
        • M mcgann

          Hello I have been trying to development a id generator but don't know exactly how to do it. The id must have an abbreviation + year(05) + id ie. refernce=abbrev+05+id. If anyone can give some advice on this it is much appreciated. Also if it helps the abbrev comes from a database on sql server. Thank You Paul Mc Gann gfhg

          H Offline
          H Offline
          HemaRawat
          wrote on last edited by
          #4

          Hey Paul, AS I Understand you want code to generate the unique Id So here is the code Public Function GenerateID() As String Dim length As Integer Dim guidResult As String length = 10 guidResult = System.Guid.NewGuid().ToString() 'removes the hyphen guidResult = guidResult.Replace("-", String.Empty) Return guidResult.Substring(0, length) End Function BY this code you can generate the desired length Unique ID Hope this works for you. Hema Chaudhry

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups