无法删除字符串之间的空格 [英] Unable to remove the blankspaces between strings

查看:73
本文介绍了无法删除字符串之间的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下逻辑从文本框中读取一组字符串.我想删除它们之间的空格
例如,我的字符串为"abcd abcd",但它正在删除字符串的第一个位置"a",但我希望它删除空格,建议我在哪里我错了我此代码,因为我想要相同的字符串但要删除空格

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

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







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



关于
Zoya



with regards
Zoya

推荐答案

使用
mStr.Remove(mVal) insted of mStr.Substring(mVal)


尝试REPLACE函数

例如:
Try the REPLACE Function

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




希望它对您有所帮助:)




Hope its helpful to you :)


嗨朋友
您可以使用过滤器文本框"扩展程序来避免通过以下代码检查文本框中的空格

要使用此文件,请不要忘记使用其.Dll文件,即与.Net Framework其指令相同版本的Ajax .dll文件,该指令将与您的母版页一起使用,或者可以直接在网页中使用.




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>


这篇关于无法删除字符串之间的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆