|
|
The following converts the version number, including lettered versions, to dotted decimal format for easy comparison. 4.6.3b becomes version 4.6302, which is definitely a "higher" version than 4.6.2a (4.6201 in this code).
' from Scott Purl (spurl@acm.org)
' Yep. Only one Dim. Session.NotesVersion holds the key.
Dim Session As New NotesSession
' Find out the version information
MyVersion = Session.NotesVersion
' Get the length of the version string
Length = Len(MyVersion)
' Discover What the "half" delimiter is, meaning what's the first non-alphanumeric character starting from the left
' Note that in the North American and International versions, this first non-alpha character differs
If MyVersion Like "*Intl*" Then
SepChar = "("
OffSet = 0
Else
SepChar = "|"
OffSet = 2
End If
' Now find this first non-alphanumeric character
SepLoc = Instr(MyVersion, SepChar)
' Get everything to the left of that character
LeftHalf = Left(MyVersion, SepLoc - 1)
' Find the only space in the left half
SpacLoc = Instr(LeftHalf, " ")
' The version number is what's left to the right of the space in the left half, minus extra spaces
' code (with bug) was VerNum = Trim(Right(LeftHalf, SpacLoc - OffSet))
VerNum = Trim(Right(LeftHalf, Len(LeftHalf) - SpacLoc - OffSet))
' Get the length of the version number
VerLen = Len(VerNum)
' Loop through the version number to remove periods
For x =1 To VerLen
CurChar = Mid(VerNum, x, 1)
If CurChar = "." Then
' Do Nothing
Else
' Keep appending non-period characters until finished
SubVer = SubVer & CurChar
End If
Next
' If the right-most character is a letter, convert it to a number
' "a" becomes "01", and "z" becomes "26"
RSubVer = Right(SubVer, 1)
If Instr("abcdefghijklmnopqrstuvwxyz", RSubVer) Then
' The first 9 letters of the alphabet need a padding leading zero
If Instr("abcdefghi", RSubVer) Then
AlphaNum = Instr("abcdefghi", RSubVer)
NewSubVer = Left(SubVer, Len(SubVer) -1) & "0" & AlphaNum
End If
' The rest of the alphabet are all greater than 10 in position
If Instr("jklmnopqrstuvwxyz", RSubVer) Then
AlphaNum = Instr("abcdefghijklmnopqrstuvwxyz", RSubVer)
NewSubVer = Left(SubVer, Len(SubVer) -1) & AlphaNum
End If
' And the numeric equivalent of the position is
SubVer = NewSubVer
End If
' Assemble it into leftmost character, plus a period, plus the rest of the iterated sub version
TextVer = Left(SubVer, 1) & "." & Right(SubVer, Len(Subver) -1)
' Convert it to a normal number so we can do quick comparisons.
FinVer = Cstr(TextVer)You can then do:
If FinVer >= 4.6302 Then 'Action if True Else 'Action if False End If