Click here to Skip to main content
15,888,100 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi guys.. im having trouble migrating to vb.net codes.. my problem is that i dont know what code is equivalent to vb6 code that im using to trim a value or text on a textbox from right or left or mid.. my code on vb6 is for example right(val(txt1.text),2).. sorry guys for my bad english..
Posted

1 solution

String.Trim[^] does both ends
String.TrimStart[^] does the left side only
String.TrimEnd[^] does only the right.

You can optionally provide a list of characters to trim, otherwise it uses just the standard white space characters.
 
Share this answer
 
Comments
lalar18 12-Oct-13 9:34am    
can u give an example of using just a variable? for example a variable holding a text of hello world, and i only want the "ld" to display on a messagebox.. tnx..
OriginalGriff 12-Oct-13 9:44am    
Ah! That's different - my mistake.
You want String.Substring:
http://msdn.microsoft.com/en-us/library/system.string.substring.aspx

Dim s As String = "Hello World"
Dim t As String = s.Substring(9)
Or
Dim s As String = "Hello World! This is text!"
Dim t As String = s.Substring(9, 2)
The first param is the zero-based index of the first character to include, and any second parameter is the number of characters to include in the new string.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900