Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compare Version Numbers
#1
Hallo,
I try to compare the version of my program with the version-number given by a PHP Serverapplication, both are Strings like x.y.z.a

But comparison with "<" does not work.

My code is like this:
Code:
Public Function versionCheck(ByVal sURL As String) As String
        Dim tmp As String = ""
        ' Prüft, ob die angegebene URL erreichbar ist
        Try
            Dim uri As New Uri(sURL)
            If (uri.Scheme = uri.UriSchemeHttp) Then
                Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
                request.Method = WebRequestMethods.Http.Get
                Dim response As HttpWebResponse = request.GetResponse()
                Dim reader As New StreamReader(response.GetResponseStream())
                tmp = reader.ReadToEnd()
                response.Close()
            End If
            Return tmp

        Catch ex As Exception
            log("myApp, version Check", ex.Message)
            ' URL not reached
            Return ex.Message
        End Try
    End Function

and this:

Code:
Dim infoString As String
        Dim actualVersion As String
        Try
            If (MC.a2UseLocalhost = True) Then
                actualVersion = MC.versionCheck("http://localhost/test-version.php")
            Else
                actualVersion = MC.versionCheck("http://ww.mytestserver.com/test-version.php")
            End If

            infoString = "Your Version: " & My.Application.Info.Version.ToString & vbCrLf & "Actual Version: " & actualVersion
            ' following does not work
            If (My.Application.Info.Version.ToString < actualVersion) Then
            infoString &= "Update needed!" & vbCrLf
            Else
            infoString &= "Programversion OK!" & vbCrLf
            End If
            MessageBox.Show(infoString)
        Catch ex As Exception
            MessageBox.Show("Error: " & ex.Message)
        End Try


Seems as if the comparison of "1.0.0.0" and "1.0.0.1" with character "<" does not work.

Any idea what's going wrong here??Unsure
Reply
#2
(05-04-2011, 03:45 AM)cipherwar Wrote: Seems as if the comparison of "1.0.0.0" and "1.0.0.1" with character "<" does not work.

Any idea what's going wrong here??Unsure

Are you just trying to see if the strings are equal? This should work for you.

Code:
.
        If string1 = string2 Then
            'same version
        Else
            'different versions
        End If
Reply
#3
thk, i implemented now this:

versionIsActual = String.Compare(My.Application.Info.Version.ToString, actualVersion)
Reply
#4
You can try:
Code:
if string1 <> string2 then
This way you will check of the 2 strings are equal or not.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  W7 Diag Tool v2.01 - New Version - Developed by AceInfinity AceInfinity 7 3,466 02-04-2012, 02:49 PM
Last Post: Denny Crane
  [Release] Shutdown Timer (My Version) euverve 13 4,675 12-11-2011, 10:53 PM
Last Post: euverve
  Red X's Custom Notepad version 3! Red X 21 6,658 08-01-2011, 01:02 PM
Last Post: Red X
  Button Game Version 2! ~ Red X Red X 22 6,139 07-31-2011, 09:04 PM
Last Post: Red X
  Help with VB 2010 (Numbers) Dεlluzion 1 869 06-22-2011, 12:07 PM
Last Post: Coding Support

Forum Jump:


Users browsing this thread: 1 Guest(s)