Dim str As String = Replace(Me.TextBox1.Text, " ", "") '替換空格
str = Replace(str, vbCrLf, "") '替換回車

解决方案 »

  1.   

    string.trim().ToString().Replace("&nbsp",null)或
    string.trim().ToString().Replace("",null);
      

  2.   

    给你一些总的替换方式:
    public static string MyHtmlEncode(string strContent)
    {
    strContent=strContent.Replace("&","&amp");
    strContent=strContent.Replace("'","''");
    strContent=strContent.Replace("<","&lt");
    strContent=strContent.Replace(">","&gt");
    strContent=strContent.Replace("chr(60)","&lt");
    strContent=strContent.Replace("chr(37)","&gt");
    strContent=strContent.Replace("\"","&quot");
    strContent=strContent.Replace(";",";");
    strContent=strContent.Replace("\r\n","<br/>");
    strContent=strContent.Replace(" ","&nbsp");
    return strContent;
    }