Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 26th, 2003, 09:47 PM
fergo fergo is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 4 fergo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
version comparison

okay. ive got to compare some versions of a program.

i have to a String, that is the version number i am comparing too, with the current verison of the program. the string is, say

sNewVersionNo = "1.3.0"

i know there are inbuilt functions in VB6 that can convert this is an integer withou the decimal points. so, i want it to become

iNewVersionNo = 130

then i can make a seperate integer for the current version number:

iCurrentVersionNo = (App.Major * 100) + (App.Minor * 10) + App.Revision

then i only have to compare to two. ie

If iNewVersionNo > iCurrentVersionNo then

my question is, how do i make a string "1.3.0" become an integer 130?

Reply With Quote
  #2  
Old November 26th, 2003, 11:47 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,179 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 10 h 3 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
This could be a round-about way to do it, but if you have

1.3.0... then you could do something like this...

Code:
dim strTemp as string
dim strTempArray() as string
dim intFinal as integer
dim i as Integer

strtemp="1.3.0" 'Put your variable holding this value here
strTempArray() = Split("1.3.0", ".")
for i = 0 to UBound(strTempArray)
     strTemp = strTemp & strTempArray(i)
next i
intfinal = cint(strTemp)


I'm fairly sure that there is a way to remove all occurences of a a string in another string, but I can't remember right now.. I'm stuck in Holiday Mode
__________________
Fisherman

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein

Reply With Quote
  #3  
Old November 27th, 2003, 09:26 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
Quote:
Originally posted by Fisherman
This could be a round-about way to do it, but if you have

1.3.0... then you could do something like this...

Code:
dim strTemp as string
dim strTempArray() as string
dim intFinal as integer
dim i as Integer

strtemp="1.3.0" 'Put your variable holding this value here
strTempArray() = Split("1.3.0", ".")
for i = 0 to UBound(strTempArray)
     strTemp = strTemp & strTempArray(i)
next i
intfinal = cint(strTemp)


I'm fairly sure that there is a way to remove all occurences of a a string in another string, but I can't remember right now.. I'm stuck in Holiday Mode


Hi,Fisherman!U give a good method,but i find a mistake which u didn't take care of:the assignment of strtemp variable.
I modify your code as:
dim strTemp as string
dim strTempArray() as string
dim strresult as string
dim intFinal as integer
dim i as Integer

strtemp="1.3.0" 'Put your variable holding this value here
strTempArray() = Split(strtemp, ".")
strresult=""
for i = 0 to UBound(strTempArray)
strresult = strresult & strTempArray(i)
next i
intfinal = cint(strresult)
__________________
Being a Code Headman !

Reply With Quote
  #4  
Old November 27th, 2003, 11:36 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,179 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 10 h 3 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
No.. I didn't worry about the reassignment of the variable. I often reuse Temp variables because I don't want to allocate more memory space for an extra variable if it's only going to be used for a small amount of functionality

Reply With Quote
  #5  
Old November 27th, 2003, 04:16 PM
fergo fergo is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 4 fergo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks guys, I used that example and it works like a charm now! I remember using the Split method now, so hopefully I'll remember it next time I need to use it!

Thanks again

Reply With Quote
  #6  
Old November 28th, 2003, 12:41 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,179 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 10 h 3 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
glad to be of service

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > version comparison


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT