str = TextBox1.Text替换:
str  = Replace(str, chr(32)," ")
str  = Replace(str, chr(13) & chr(10),"<BR>")替换回来:
str  = Replace(str, "&nbsp;"," ")
str  = Replace(str, "<BR>",chr(13) & chr(10))

解决方案 »

  1.   

    错误的,VB中没有Replace这个函数!
      

  2.   

    呵呵不好意思,有的:Visual Basic Scripting Edition Language Reference --------------------------------------------------------------------------------Replace Function
    Returns a string in which a specified substring has been replaced with another substring a specified number of times.Replace(expression, find, replacewith[, start[, count[, compare]]])Arguments
    expressionRequired. String expression containing substring to replace. findRequired. Substring being searched for.replacewithRequired. Replacement substring.startOptional. Position within expression where substring search is to begin. If omitted, 1 is assumed. Must be used in conjunction with count.countOptional. Number of substring substitutions to perform. If omitted, the default value is -1, which means make all possible substitutions. Must be used in conjunction with start.compareOptional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values. If omitted, the default value is 0, which means perform a binary comparison.
      

  3.   


    Replace函数
          描述返回一个字符串,该字符串中指定的子字符串已被替换成另一子字符串,并且替换发生的次数也是指定的。语法Replace(expression, find, replacewith[, start[, count[, compare]]])Replace函数语法有如下几部分:部分 描述 
    expression 必需的。字符串表达式,包含要替换的子字符串。 
    find 必需的。要搜索到的子字符串。 
    replacewith 必需的。用来替换的子字符串。 
    start 可选的。在表达式中子字符串搜索的开始位置。如果忽略,假定从1开始。 
    count 可选的。子字符串进行替换的次数。如果忽略,缺省值是 –1,它表明进行所有可能的替换。 
    compare 可选的。数字值,表示判别子字符串时所用的比较方式。关于其值,请参阅“设置值”部分。 
    设置值compare参数的设置值如下:常数 值 描述 
    vbUseCompareOption –1 使用Option Compare语句的设置值来执行比较。 
    vbBinaryCompare 0 执行二进制比较。 
    vbTextCompare 1 执行文字比较。 
    vbDatabaseCompare 2 仅用于Microsoft Access。基于您的数据库的信息执行比较。 
    返回值Replace的返回值如下:如果 Replace返回值 
    expression长度为零 零长度字符串("")。 
    expression为Null 一个错误。 
    find长度为零 expression的复本。 
    replacewith长度为零 expression的复本,其中删除了所有出现的find 的字符串。 
    start > Len(expression) 长度为零的字符串。 
    count is 0 expression.的复本。 
    说明Replace函数的返回值是一个字符串,但是,其中从start所指定的位置开始,到expression字符串的结尾处的一段子字符串已经发生过替换动作。并不是原字符串从头到尾的一个复制。