|
-
Jul 25th, 2010, 07:38 AM
#1
Thread Starter
Fanatic Member
[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
Last edited by Arve K.; Jul 25th, 2010 at 07:49 AM.
-
Jul 25th, 2010, 08:08 AM
#2
Hyperactive Member
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
-
Jul 25th, 2010, 08:09 AM
#3
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
Last edited by chris128; Jul 25th, 2010 at 08:51 AM.
-
Jul 25th, 2010, 08:16 AM
#4
Thread Starter
Fanatic Member
Re: Comparing versions = Headache
I told you it probably was a neat way of doing this 
Thank you both
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|