how to format number "0000"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nickyazura
    New Member
    • Mar 2008
    • 4

    how to format number "0000"

    hello,
    i would like to know how to do numbering format for "0000" where each time it will generate 0001,0002,0003 and so on untill 9999.

    counter = "0000"
    counter = counter + 1
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    Try This :

    Declare MyCounter as Form Level Variable as Integer

    [code=vb]
    'Code in Form Load:
    MyCounter = 0
    'Code to get next Number:
    MyCounter = MyCounter + 1
    Text1.Text = Format(MyCounte r,"0000")
    [/code]

    Regards
    Veena

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      try using this

      [code=vb]
      Private Sub Command1_Click( )
      Static cnt As Integer
      cnt = cnt + 1
      Text1.Text = Format(cnt, "0000")
      End Sub
      [/code]

      Comment

      • nickyazura
        New Member
        • Mar 2008
        • 4

        #4
        i'm using VB 6.0 and is this code can be run on VB 6.0?i already test it, it cannot generate 0001,0002.
        By the way thank you for answering my question. Really appreciate it

        Comment

        • QVeen72
          Recognized Expert Top Contributor
          • Oct 2006
          • 1445

          #5
          Hi,

          Yes the Code is for VB6..
          So you have tested..
          If it is not correct, then what is shown in the TextBox...?

          REgards
          Veena

          Comment

          • debasisdas
            Recognized Expert Expert
            • Dec 2006
            • 8119

            #6
            Are you facing any problem or getting any error in the code ?

            Comment

            • SharjeelSaleem3
              New Member
              • Apr 2021
              • 1

              #7
              Thank You

              Thank You .......
              It worked perfectly ...............

              Comment

              Working...