Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am reading a set of strings from the textbox using following logic .I want to remove the blank spaces between them
for eg i have string as "abcd abcd" but it is removing the first position "a" of the string but i want it to remove the spaces, suggest me where I am wrong i this code as i want the same string but removing spaces

VB
Dim str As String = ReadDelimeter(TextBox1.Text)
               mStr = TextBox1.Text.Replace(str, "")
               TextBox1.Text = TextBox1.Text.Remove(0, Len(mStr))



VB
Private Function ReadDelimeter(ByVal mStr As String) As String
        Dim mVal As Integer = 0, mVal1 As String = " "
        mVal = InStr(1, mStr, " ")
        If mVal > 0 Then
            mVal1 = mStr.Substring(mVal)
        End If
        Return mVal1.ToString
    End Function


with regards
Zoya
Posted

use
mStr.Remove(mVal) insted of mStr.Substring(mVal)
 
Share this answer
 
v2
Comments
Rajesh Anuhya 13-Feb-12 6:36am    
Edited: Code Tags added.
--RA
zoyakhan 13-Feb-12 11:21am    
Thanks for the prompt reply , ihave try the mstr.remove(mval) , but it is returning the first alphabet now how i can remove that alphabet
Try the REPLACE Function

ex:
NewString = REPLACE(OldString," ","")



Hope its helpful to you :)
 
Share this answer
 
v2
Comments
Rajesh Anuhya 13-Feb-12 6:37am    
Edited: "Treat my content as plain text, not as HTML" checkbox disabled.
--RA
hi friend
you can use Filter Textbox extender to avoid spaces in Textbox check by below code

To use this Don't forget to use its .Dll File i.e. Ajax .dllfile of version same to the .Net Framework its directive that you will use with your master page or directly you can use in webpage




<asp:filtertextboxextender id="FT_Removespaces" runat="server" setfocusonerror="true" filtertype="Numbers,Consonants,LowerCase,UpperCase" filtermode="" display="Dynamic" xmlns:asp="#unknown"></asp:filtertextboxextender>
 
Share this answer
 
v2
Comments
Rajesh Anuhya 13-Feb-12 6:38am    
Edited: Code Tags added.
--RA
This is working for me check it and use it according to ur program:

VB
Sub Main()
        Dim Str As String = "i m a .net programer"
        Str = Str.Replace(" ", "")

        Console.WriteLine(Str)
        Console.ReadKey();

    End Sub
 
Share this answer
 
Comments
zoyakhan 19-Feb-12 11:05am    
thanks for the responses.

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