[RESOLVED] Comparing versions = Headache
Hi guys,
In my application I need to compare two versions against each other, but I'm not quite sure how to go on with this. The structure of the versions is like this; Major, Minor, Build, Revison (ex: 1.0.0.0).
Example:
So if I compare 1.0.0.10 with 1.3.0.3, I'm thinking that I need to split each version into 4 integers and then compare them with the 4 integers in the other version, but that would require a lot of If's and Then's, wouldn't it?? There is probably a neat way of doing this, but I can't come up with nothing at the moment...
Any ideas??
Arve
Re: Comparing versions = Headache
You can just use simple comparision between two versions ;)
VB.Net Code:
Dim v1 As Version = My.Application.Info.Version
Dim v2 As Version = New Version("1.0.0.10")
If v2 > v1 Then
' do something
Else
' do something
End If
Re: Comparing versions = Headache
You can use the Version class, like so:
Code:
Dim Version1 As New Version("1.0.2.4")
Dim Version2 As New Version("1.3.2.1")
If Version1 > Version2 Then
MessageBox.Show("Version 1 is newer")
ElseIf Version2 > Version1 Then
MessageBox.Show("Version 2 is newer")
Else
MessageBox.Show("Both versions are the same")
End If
Re: Comparing versions = Headache
I told you it probably was a neat way of doing this ;)
Thank you both :)