473,803 Members | 3,766 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculate version number for comparison?

Tom
I have two version numbers - one for my application and another from a
manifest, database, whatever - that isn't important. Now that I have these
two version numbers (in the form major.minor.bui ld.revision) I want to
compare one to see if it is less than the other.

Is there any calculation I can do to convert a version number to a 'real'
number so that I can compare it easily? I've fiddled around with various
methods but nothing works for everything. I have tried to compare the
individual elements one at a time, but there are so many deviations that it
again doesn't work for everything (i.e. 1.9.9.0 is higher than 1.9.8.920).

There seems like there should be some mathematical way to convert this to
some kind of number so my code could simply say something like "if
current_convert ed_version < new_converted_v ersion then ...'.

Anyone good mathematicians out there?? :-)

Tom
Nov 20 '05 #1
1 6630
Tom,
If you have two System.Version objects, you can simply use Version.Compare To
& Version.Equals to compare two versions in VB.NET. If you are using C# then
you can use the overloaded operators to compare Versions.

Dim v1, v2 As System.Version
If v1.CompareTo(v2 ) < 0 Then
' v1 is less then v2
End If
System.Version v1, v2;
if (v1 < v2)
{
// v1 is less then v2
}

Note in VS.NET 2005 (Whidbey, due out in 2005) the overloaded comparison
operators can be used.

Note there are constructors on System.Version that accepts a string in
major.minor.bui ld.revision format or as 1 to 4 integers.

Be certain to read the help on Version.Compare To method for some important
tips.

Hope this helps
Jay

"Tom" <to*@nospam.com > wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
I have two version numbers - one for my application and another from a
manifest, database, whatever - that isn't important. Now that I have these two version numbers (in the form major.minor.bui ld.revision) I want to
compare one to see if it is less than the other.

Is there any calculation I can do to convert a version number to a 'real'
number so that I can compare it easily? I've fiddled around with various
methods but nothing works for everything. I have tried to compare the
individual elements one at a time, but there are so many deviations that it again doesn't work for everything (i.e. 1.9.9.0 is higher than 1.9.8.920).

There seems like there should be some mathematical way to convert this to
some kind of number so my code could simply say something like "if
current_convert ed_version < new_converted_v ersion then ...'.

Anyone good mathematicians out there?? :-)

Tom

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4025
by: Phil Powell | last post by:
Relevancy scores are normally defined by a MySQL query on a table that has a fulltext index. The rules for relevancy scoring will exclude certain words due to their being too short (minimum default is 4 letters). This is the Fed. Everything is a TLA (three-letter acronym). Therefore, since I'm building a PORTABLE web application, changing MySQL's default settings for fulltext index querying is completely undoable and unrealistic, so...
1
13140
by: David | last post by:
Can someone help me with this. I need to calculate the week ending date of the first week of the year based upon a year provided by the user. Is there a simpler way other than writing my own UDF?
1
9998
by: Building Blocks | last post by:
Hi, All I need is a simle calculate form script which contains this: A script that can handle text input, radio buttons, checkboxes, and dropdowns. Each one of these variables will contain a number. That number will appear in a seperate box at the bottom. So basically whatever you choose has a corresponding number associated with it (except for the text input, which you enter whatever number) and those numbers are added and produced in...
28
742
by: Steve | last post by:
Hi all How would I find out the average date when given a bunch of dates? For example, I want to find the average length in time from the following dates: ---------------------------------------------------- Start Date End Date 01/01/2004 12:50pm 02/01/2004 18:40pm 02/01/2004 13:40pm 02/01/2004 13:57pm 02/01/2004 14:30pm 02/01/2004 19:50pm
1
6093
by: bin_P19 P | last post by:
the code i have got is as follows and now im stuck <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Shopping Cart</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="StyleSheet" href="css/style.css" type="text/css">
1
13606
by: sg_s123 | last post by:
============================================================================ 02-Feb-04 03-Feb-04 Staff Staff 0800hr- 1300hr- 1700hr- 1900hr- 0800hr- 1300hr- 1700hr- 1900hr- Number Name 1200hr 1700hr 1900hr 2200hr 1200hr 1700hr 1900hr 2200hr ============================================================================ 4654 Saniff A A A C A A A C 4437 Joey B C B C B C B C 4479 Elmer C C B C C C B C
1
2297
by: comp.lang.php | last post by:
I have written several applications that have very specific functionality that is version-dependent, furthermore, requirements dictate my apps span multiple versions of PHP. I have written a function that detects which version of PHP and ultimately converts it into integer form, however, I am foreseeing a problem in doing this which I will illustrate to you now: if (!function_exists('get_php_version_int')) {
3
5965
by: Libber39 | last post by:
Hi everyone, Have a query on how to calculate the amount of weeks and days contained in a number in an access query. ie: the difference in days between 2 dates amounts to 17 days. I want to now calculate in the query the amount of weeks and days within the 17 days to show 2 weeks 3 days. I can create the function within excel, (A1 as cell with the days within it) as: =INT(A1/7) & " Weeks, " & MOD(A1,7) & " days" but cant seem to...
3
8519
by: supperham | last post by:
hi: can sone one tell me how to use fedex web service in php to calculate shipping fee? i already have fedex account and 4 keys used to test application Test Password:8pVQ6p5cHyQVuJJvrfosaBKqG Developer Test Key: vfNOPSmeA69gJFdf Test Account: 510087682 Test Meter: 1239156
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9569
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2975
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.