fkheng Posted June 5, 2003 Posted June 5, 2003 How do I remove spaces from a string if I only want a single word? What is the method for doing it? Quote Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
zy_abc Posted June 5, 2003 Posted June 5, 2003 If you want to extract a single letter from a word you can use "SubString". If you want to remove blank spaces then you can use "Trim" Quote Thanks & Regards, zy_abc
Leaders dynamic_sysop Posted June 5, 2003 Leaders Posted June 5, 2003 Dim strString As String strString = "some text" strString = Replace(strString , Chr(32) , "" ) '// strString now would show as "sometext" Quote
fkheng Posted June 5, 2003 Author Posted June 5, 2003 i see, thanx, will try these out, very helpful indeed... Quote Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
Mothra Posted June 9, 2003 Posted June 9, 2003 Isn't that what .Trim is for? Quote Being smarter than you look is always better than looking smarter than you are.
fkheng Posted June 9, 2003 Author Posted June 9, 2003 yeah, it is, but i did not know before... Quote Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
iebidan Posted June 18, 2003 Posted June 18, 2003 Trim will do the trick Dim myString as String = " Your Name Here " myString = Trim(myString) Quote Fat kids are harder to kidnap
*Experts* Bucky Posted June 18, 2003 *Experts* Posted June 18, 2003 Or, yet another option, split up the trimmed text into words by using the Split method, and then access the word in an array. Dim s As String = " this is a test " Dim words() As String words = s.Trim().Split(" "c) Console.WriteLine(words(1)) ' Displays "is" Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Grimfort Posted June 20, 2003 Posted June 20, 2003 In .Net if you use the built in functions created specifically for a class, you get better performance, and its also easier. For those of you new to .net, just and an extra STOP charcater at the end of a variable, in this case you can do strString = strString.Replace(" ","") Quote
fkheng Posted June 21, 2003 Author Posted June 21, 2003 wat do u mean by this stop character? Quote Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
*Experts* Bucky Posted June 21, 2003 *Experts* Posted June 21, 2003 He means the period character. In other words, use the native functions of the String class to perform string manipulation, rather than the old VB6 methods. For example, instead of myString = Trim(myString) (bad), use myString = myString.Trim() Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.