string comparison

jutiyi

Member
Joined
Feb 16, 2005
Messages
14
Programming Experience
1-3
here i want to compare two string.One is get from sql database-one is get from textfile.

If they equal the message box show No Update Version Available
If thay are different message box show Update Version Available.Please Click ok to start download


But now whether thay ara same or not the massage box always show Update Version Available.Please Click ok to start download

below is my source code



Dim web As New FTPWeb.Service1
Dim ShowNewVersion As New DataSet

ShowNewVersion = web.ShowNewVersion

Dim NewVersion As String = Convert.ToString(ShowNewVersion.Tables(0).Rows(0).Item("Version"))

'read the version textFile

Dim tr As TextReader ' declare TextReader to read the file contents

tr = File.OpenText(CurDir() + "\..\Version.txt") ' Open the file to be Read. Change Path to match the Path your file is in.

Dim OldVersion As String ' declare String to hold File contents

OldVersion = tr.ReadLine

tr.Close()

Label1.Text = OldVersion

Label2.Text = NewVersion



'compare new version and old version

If OldVersion.Equals(NewVersion) Then



MsgBox("No Update Version Available", MsgBoxStyle.Information)

Else

MsgBox("Update Version Available.Please Click ok to start download", MsgBoxStyle.OKOnly)

Me.Hide()

Dim Downloading As New Form1

Downloading.ShowDialog()

End If

Please help!!!Thanks
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
basically what your looking for is an exact match, in which the way i check for it is simply this:

If strOldVersion = strNewVersion then
Messagebox.Show("You have the latest version")
Else
Messagebox.Show("A newer version is available")
End If
 
Top Bottom