Reputation: 95
My current code is:
Dim currentversion As String = File.ReadAllText("C:\lol\update\currentversion.txt")
Dim newversion As String = File.ReadAllText("C:\lol\update\new.txt")
If currentversion Is newversion Then
MessageBox.Show("VERSION IS THE SAME")
End If
If currentversion Is Not newversion Then
MessageBox.Show("VERSION IS NOT THE SAME")
End If
Why are the strings not the same? What's wrong? In both text files is the same MEGA link, like "https://mega.nz/#!i8NgdfgdfgvufFf638vqGt7sA_yGdrefdgeVrnf_E3434" (link inst real now).
Thx for ur help!
Upvotes: 0
Views: 70
Reputation: 218808
Because they're different objects:
Dim currentversion
Dim newversion
Separate variables, separate instances in memory, separate references. And the Is
operator compares references, not values. If you want to compare the values, you're looking for the equals operator:
If currentversion = newversion Then
'...
Else
'...
End If
Or perhaps .Equals()
depending on the objects being compared and if they implement that:
If currentversion.Equals(newversion) Then
'...
Else
'...
End If
Beyond that, it's possible that the strings aren't equal. They are being read from different files after all...
Upvotes: 4