Last post Sep 20, 2009 10:03 PM by David Anton
Sep 19, 2009 09:43 PM|n64luke123|LINK
Title pretty much says it all. I know how to cut off characters at the end of a string using vb script, which uses the LEFT(string, #) syntax, however, how do i do this using vb.net?
and my second question, I have a string being sent into a drop down menu that gets the data pulled from an access database using a data source control. How do I format it so say, it only shows the first 100 characters of that string in the dropdown? I
have a feeling i can use that 'datatextformatstring' attribute, but I dont know how that would be done.
Thanks for any help.
Sep 19, 2009 10:53 PM|whighfield|LINK
Use the strings SubString function
' use Substring(index, length)
'index = the index of the character to start from
'length = the number of characters to take.
Dim s As String = "abcdefghijklmnopqrstuvwxyz"
s = s.Substring(0, 12)
' s is now "abcdefghijkl"
Sep 20, 2009 10:03 PM|David Anton|LINK
Although "Substring" is more consistent with other .NET languages, note that "Left" is still available.
If it doesn't work as is, try qualifying with 'Strings' (the VisualBasic dll class which contains these functions).
e.g., Strings.Left(string, #)