Single quotes inside vb.net string
I need to display single quote inside a warning message in my application. I am expecting the string to be "Error User name should not have ' character". But application displays as "Error User name should not have \' character". I tried with Chr(39) also but it didnt work.


Nattudurai EswaramurthyRank #5,536 · 296 reputationPosted Jun 18, 2012, 3:56 AM EDT
Nattudurai EswaramurthyRank #5,536 · 296 reputationPosted Jun 18, 2012, 4:00 AM EDT
Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Jun 18, 2012, 4:16 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jun 18, 2012, 4:24 AM EDT
MessageBox.Show("Error User name should not have ' character")
Are you perhaps trying to escape the ' by preceding it with a backslash as you would in C#?
If so, this is unnecessary in VB.NET which doesn't use escape sequences.
Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Jun 18, 2012, 4:31 AM EDT
My actual code is
Else
Throw New Exception("The Following Problem occured:Character ' is Invalid.Please change the name")
End If
If (lastname.Success) Then
Else
Throw New Exception("The Following Problem occured:Character ' is Invalid.Please change the name")
But when i try with console application or someother applications, its working with the above string. But in my project for the above code, its coming \'
VulpesRank #55 · 29.2K reputationPosted Jun 18, 2012, 4:39 AM EDT
What kind of project are you writing and how are you displaying the exception string to the user?
Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Jun 18, 2012, 4:52 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jun 18, 2012, 5:10 AM EDT
Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Jun 18, 2012, 5:30 AM EDT
Ya i thought about it, but that would be my last option if i couldnt figure out and fix.