|
-
Mar 26th, 2007, 11:44 PM
#1
Thread Starter
Member
[RESOLVED] [2005] Removing Space(s) within a string
Hi everyone!
I just wanna ask on how to remove space(s) within a string. For example, I have a string "Hello world" and my output should be "Helloworld".
I've already used the Trim Function but it won't give me the desired output.
Thanks a lot!
Radic
Last edited by radic; Mar 26th, 2007 at 11:53 PM.
-
Mar 26th, 2007, 11:58 PM
#2
Re: [2005] Removing Space(s) within a string
Use the Replace method. Also, please provide descriptive titles for your threads.
-
Mar 27th, 2007, 12:00 AM
#3
Re: [2005] Removing Space(s) within a string
vb Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim s As String = "Hello World"
MessageBox.Show(s.Replace(" ", ""))
End Sub
-
Mar 27th, 2007, 12:04 AM
#4
Thread Starter
Member
Re: [RESOLVED] [2005] Removing Space(s) within a string
-
Mar 27th, 2007, 12:08 AM
#5
Re: [RESOLVED] [2005] Removing Space(s) within a string
This is a small thing and not specifically related to the question but you should not use literal empty strings. It is "more correct" to use the String.Empty property:
vb Code:
MessageBox.Show(s.Replace(" ", String.Empty))
-
Mar 27th, 2007, 12:19 AM
#6
Thread Starter
Member
Re: [RESOLVED] [2005] Removing Space(s) within a string
-
Mar 27th, 2007, 12:24 AM
#7
Re: [RESOLVED] [2005] Removing Space(s) within a string
 Originally Posted by jmcilhinney
This is a small thing and not specifically related to the question but you should not use literal empty strings. It is "more correct" to use the String.Empty property:
vb Code:
MessageBox.Show(s.Replace(" ", String.Empty))
Again Forget
Thanks for That
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|