首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Trim函数不会从任何边删除任何空格

Trim函数不会从任何边删除任何空格
EN

Stack Overflow用户
提问于 2019-12-11 09:17:35
回答 1查看 37关注 0票数 0

我尝试使用宏来裁剪Calc中的空格。Trim函数似乎不起作用

我尝试使用Trim,LTrim,RTrim,但结果相同。有人知道哪里错了吗?

oCSL是“阿朗和法官”

oCSR和z在修剪后也应该像oCSL一样,但仍然留在"Arang和地方法官“。

代码如下:

代码语言:javascript
运行
复制
Dim oAC As Object, oC As Object, oAS As Object, oCSL As String, oCSR As String
Dim oASn As Integer
Dim CellRangeAddress As New com.sun.star.table.CellRangeAddress
Dim CellAddress As New com.sun.star.table.CellAddress
oC = ThisComponent
oAS = oC.getcurrentcontroller.ActiveSheet
oASn = oC.getCurrentController().getActiveSheet().getRangeAddress().sheet

Dim Ll As Integer, Lc As Integer, r As Integer
Dim z As String, y As String
Ll = 400
Lc = 0
r = 400

' Read Each Left Side Line
Do
    Do
        ' Locate Position For Right Side
        Do
            oCSL = Trim(UCase(oAS.getCellByPosition(Lc, Ll).String))    ' oSCL Value Returned "Arang and the Magistrate"
            oCSR = Trim(UCase(oAS.getCellByPosition(7, r).String))      ' oCSR Value Returned "Arang and the Magistrate   "

z = RTrim(oAS.getCellByPosition(7, r).String)         ' z Returns Also "Arang and the Magistrate   "
            If strcomp(oCSL, oCSR) < 0 Then
            ThisComponent.CurrentController.Select(oAS.getCellByPosition(7, r))     ' Reposition Selected Area
                'ThisComponent.CurrentController.Select(oAS.getCellByPosition(Lc, Ll))      ' Reposition Selected Area
                MsgBox ("At " & r & " Not Found " & Chr(13) & oCSL)         ' Not Found
                ' Insert New Movie
                Exit Do
            else
                If UCase(oCSL) = UCase(OcSR) Then
                    ThisComponent.CurrentController.Select(oAS.getCellByPosition(7, r))     ' Reposition Selected Area
                    'MsgBox ("At " & r & " Same Value " & oCSL)     ' Same Value
                    r = r + 1
                    Exit Do
                else
                    r = r + 1
                End If
            End If
        Loop While Lc <= 4
        Lc = Lc + 1
    Loop While Lc <= 4
    Ll = Ll + 1                         ' Next Line
    Lc = 0                              ' Reset Column
Loop While oCSL <> ""                   ' getCellByPosition Starts From Col 0 Row 0
EN

回答 1

Stack Overflow用户

发布于 2019-12-12 13:28:25

我找到原因了。在使用Asc()来判断它是否是空格之后,它不是空格,而是特殊字符。很抱歉打扰了大家。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59277608

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档