My string comparison doesnt work.I tried compare,equals ,= and all of these methods doesnt work.
Here’s my code:
Dim activeChild2 = Me.ActiveMdiChild
If TypeOf activeChild2 Is Window Then
Dim activeChild As Window = Me.ActiveMdiChild
If (Not activeChild Is Nothing) Then
If activeChild.CTR_User.ToString = activeChild.User_name.ToString Then
Call activeChild.Edition()
Select Case Trim$(UCase(activeChild.Name))
Case "FRM_MISSION"
'treatment
Case "FRM_TACHE"
'treatment
End Select
Else
MsgBox("Error modification!!!!", MsgBoxStyle.Critical)
End If
End If
End If
The problem is in If activeChild.CTR_User.ToString = activeChild.User_name.ToString Then .In spite of having same string toto=toto the code always fires to the else clause and show me the msgbox
Regards
Why are you calling .ToString? Are activeChild.CTR_User and activeChild.User_name strings, or are they objects that you’re trying to compare?
If they’re objects, you can’t compare them with .ToString(), as it will be inaccurate. you should use something like
activeChild.CTR_User.Equals(activeChild.User_name)oractiveChild.CTR_User is activeChild.User_name. I can’t really give you specifics unless I know what types you’re working with.Have you tried putting a breakpoint on it and checking the values manually within Visual Studio’s many debugging tools?