AM trying to use a string "0000" to generate an auto number. i.e 0000 +1 to increment to 0001. how do i achieve this.

AM trying to use a string "0000" to generate an auto number. i.e 0000 +1 to increment to 0001. how do i achieve this.

**************************************************

hope this one helps...

dim x as integer        'declare first variable

x = 0                      'set the value of your variable

for x = 1 to 2000

    s = len(str(x))      'here we will check the length of x
    
    select case s

          case 1
                      x2 = "000" & str(x)
          case 2
                      x2 = "00" & str(x)
          case 3
                      x2 = "0" & str(x)
          case 4
                      x2 = str(x)

    end select

next x

msgbox str(x2)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.