Results 1 to 9 of 9
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SUMM + 1 in a string (2000)

    I have a value dimensioned as String named test_1

    i want to summ +1 to the string with a loop or for next in this format 0001, 0002, 0003...0987
    how to?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: SUMM + 1 in a string (2000)

    Does this do what you want?

    Dim intCount As Integer
    For intCount = 1 To 987
    test_1 = Format(intCount, "0000")
    ...
    Next intCount

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SUMM + 1 in a string (2000)

    !!!!!!!!!!!!!!!
    No words!
    Tks.

  4. #4
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SUMM + 1 in a string (2000)

    but...
    - Instead to use as integer i use as long for counter there is different?
    - i use a format "#0000" instead "0000" there is difference?

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: SUMM + 1 in a string (2000)

    Long can go up to 2147483647, while the maximum value for Integer is 32767. So if you never go higher than 32767, you only need an Integer, but using a Long instead is OK too. If you need to go higher than 32767, you must use a Long.

    "#0000" and "0000" format a number exactly the same way.

  6. #6
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SUMM + 1 in a string (2000)

    Gentleman!
    Tks for explain...

  7. #7
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SUMM + 1 in a string (2000)

    To Hans's response in <post:=758,879>post 758,879</post:> I would add two things:

    (1) In my experience trying to economize on size/space for the end-user often results in problems/bugs with data overflow that cost more than the anticipated savings
    (2) I saw, once, long long ago, in some forum or other, that VBA at least employed LONGs efficiently, and stored or manipulated INTEGERs as LONGs anyway, sot at using INTEGER meant you went into LONG and back again. A terrible waste.

    I use INTEGER only for file handling that is, Free File and the Open/Close/Print/Write set of statemenst.

    I can't swear to (2) above, but I swear to (1) above.

  8. #8
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: SUMM + 1 in a string (2000)

    Thanks for that Chris. You have justified my lazy habit of using long for all whole number activities.
    Regards
    Don

  9. #9
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SUMM + 1 in a string (2000)

    >You have justified my lazy habit of using long for all whole number activities.

    No sweat, Don.
    I got paid overtime at <img src=/S/money.gif border=0 alt=money width=17 height=15> <img src=/S/money.gif border=0 alt=money width=17 height=15> -and <img src=/S/money.gif border=0 alt=money width=17 height=15> <img src=/S/money.gif border=0 alt=money width=17 height=15> <img src=/S/money.gif border=0 alt=money width=17 height=15>-rates in the UK back in '78 for learning that.
    An old ICL 1900 with 24-bit words, payroll crashing each weekend (hence double-, triple-!) with various totals being always 2^23-1 === 83,886.07 pounds shy of the predicted totals.
    Lovely work, if you can get it!

Posting Permissions

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