修剪所有类型的空格,包括制表符 [英] Trim all types of whitespace, including tabs

查看:32
本文介绍了修剪所有类型的空格,包括制表符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 VB6 中,Trim() 函数修剪字符串前后的空格.我想知道是否有一个函数不仅可以修剪空格,还可以修剪字符串两端的所有空格(在本例中为制表符).

In VB6, the Trim() function trims spaces off the front and back of a string. I am wondering if there is a function that will trim not just spaces, but all whitespace (tabs in this case) off of each end of a string.

推荐答案

遗憾的是没有内置函数.这是我写的一篇.它可以解决问题.

It's a shame there is no built in function. Here is the one I wrote. It does the trick.

Function TrimAllWhitespace(ByVal str As String)

    str = Trim(str)

    Do Until Not Left(str, 1) = Chr(9)
        str = Trim(Mid(str, 2, Len(str) - 1))
    Loop

    Do Until Not Right(str, 1) = Chr(9)
        str = Trim(Left(str, Len(str) - 1))
    Loop

    TrimAllWhitespace = str

End Function

这篇关于修剪所有类型的空格,包括制表符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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