Sometimes i seem to be able to use them without problems but sometimes they don't work? Can anybody tell me what im doing wrong? thnx
Printable View
Sometimes i seem to be able to use them without problems but sometimes they don't work? Can anybody tell me what im doing wrong? thnx
well there is no left and right as part of the string class..you now have SubString with the parameters (startingposition, length)
if you want to get left 2 characters..you say
blah = thestring.Substring(0,2)
to get the right 2 characters of a string
blah = thestring.SubString(thestring.length - 2,2)
left and right I believe are just part of the Microsoft.VisualBasic class which is there solely for some backwards comatability..I try to avoid it as you do everything you could do in VB with the new stuff the framework provides.
Two ways:
Left() = strString.SubString(0, length)
Right() = strString.SubString((strString.length - <how many characters from the right you want to return>))
you can also import the Microsoft.VisualBasic namespace and use the Left and Right functions.
boy are we ever on the same track..arent we Thelonius?:D
nearly the exact same answer
And posted within seconds of each other.
OK i found it out :-) thank you very much guys!
Another way you can do it from the way listed above is to do something similar to the following:
Dim test As String = Microsoft.VisualBasic.Left( str as string, length as Integer)
Dim test As String = Microsoft.VisualBasic.Right( str as string, length as Integer)
Dim test As String = Microsoft.VisualBasic.Mid(str as string, Start as Integer, Length as Integer)
Just providing another avenue of attack. Hope it helps