increase value

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

increase value

Post by sal21 »

I have this value in myvar ="Ver. 1.0.3"
How to increase of 0.0.1 this value?

Similar:
Ver. 1.0.4
Ver. 1.0.5
...
Ver. 2.1.9

User avatar
HansV
Administrator
Posts: 78475
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: increase value

Post by HansV »

What comes after 1.0.9? Is the next value
a) 1.0.10
b) 1.1.0
c) 1.1.1
d) something else - and if so, what?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

Re: increase value

Post by sal21 »

HansV wrote:What comes after 1.0.9? Is the next value
a) 1.0.10
b) 1.1.0
c) 1.1.1
d) something else - and if so, what?
I think this format
a) 1.0.10

but in effect the number refer similar a Version of apps, choice you based your experince the appropriate value:-)

User avatar
HansV
Administrator
Posts: 78475
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: increase value

Post by HansV »

For example:

Code: Select all

    Dim p As Long
    Dim n As Long
    p = InStrRev(myVar, ".")
    n = Mid(myVar, p + 1)
    myVar = Left(myVar, p) & (n + 1)
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

Re: increase value

Post by sal21 »

HansV wrote:What comes after 1.0.9? Is the next value
a) 1.0.10
b) 1.1.0
c) 1.1.1
d) something else - and if so, what?

ops...
Hans sorry, but really i need after 1.0.9
1.1.0

Possible to modify yyour code, in effect i need the b option.?

User avatar
HansV
Administrator
Posts: 78475
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: increase value

Post by HansV »

That requires very different code:

Code: Select all

    Dim arrParts As Variant
    Dim n As Long
    Dim v As Long
    arrParts = Split(myVar, ".")
    n = UBound(arrParts)
    v = Val(arrParts(n))
    If v < 9 Then
        arrParts(n) = v + 1
    Else
        arrParts(n) = 0
        v = Val(arrParts(n - 1))
        If v < 9 Then
            arrParts(n - 1) = v + 1
        Else
            arrParts(n - 1) = 0
            v = Val(arrParts(n - 2))
            arrParts(n - 2) = " " & (v + 1)
        End If
    End If
    myVar = Join(arrParts, ".")
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

Re: increase value

Post by sal21 »

HansV wrote:That requires very different code:

Code: Select all

    Dim arrParts As Variant
    Dim n As Long
    Dim v As Long
    arrParts = Split(myVar, ".")
    n = UBound(arrParts)
    v = Val(arrParts(n))
    If v < 9 Then
        arrParts(n) = v + 1
    Else
        arrParts(n) = 0
        v = Val(arrParts(n - 1))
        If v < 9 Then
            arrParts(n - 1) = v + 1
        Else
            arrParts(n - 1) = 0
            v = Val(arrParts(n - 2))
            arrParts(n - 2) = " " & (v + 1)
        End If
    End If
    myVar = Join(arrParts, ".")

"That requires very different code" :sad: :sad: , sorry me.