在宏中使用 libreOffice Calc 函数

在宏中使用 libreOffice Calc 函数

我正在尝试在 calc 中创建一个基本的宏函数来执行超过 10 位的十六进制到二进制的转换。但我遇到了很多麻烦。

首先,我在哪里可以找到实际的文档?我只找到了很少的例子,没有多大帮助,而且基本指南也相当简洁。

主要是(如果首先没有响应),正如您在下面的示例中看到的,我试图CONCATENATE在宏中使用。这是电子表格中一个完美运行的函数。但我收到以下错误消息:

Sub-procedure or function procedure not defined.

那么,如何在宏中使用这样的函数,可能吗?

这是我的宏的代码:

Function HEX2BINREAL(hexIn as string) as string

   n = len(hexIn)
   Dim binOut as string
   binOut = ""

   For i = 1 to n
      ActChar = Mid(hexIn,i,1)
      Select Case ActChar
        Case "0"
            binOut = CONCATENATE(binOut,"0000")
        Case "1"
            binOut = CONCATENATE(binOut,"0001")
        Case "2"
            binOut = CONCATENATE(binOut,"0010")
        Case "3"
            binOut = CONCATENATE(binOut,"0011")
        Case "4"
            binOut = CONCATENATE(binOut,"0100")
        Case "5"
            binOut = CONCATENATE(binOut,"0101")
        Case "6"
            binOut = CONCATENATE(binOut,"0110")
        Case "7"
            binOut = CONCATENATE(binOut,"0111")
        Case "8"
            binOut = CONCATENATE(binOut,"1000")
        Case "9"
            binOut = CONCATENATE(binOut,"1001")
        Case "a", "A"
            binOut = CONCATENATE(binOut,"1010")
        Case "b", "B"
            binOut = CONCATENATE(binOut,"1011")
        Case "c", "C"
            binOut = CONCATENATE(binOut,"1100")
        Case "d", "D"
            binOut = CONCATENATE(binOut,"1101")
        Case "e", "E"
            binOut = CONCATENATE(binOut,"1110")
        Case "f", "F"
            binOut = CONCATENATE(binOut,"1111")
        End Select
   next i
HEX2BINREAL = binOut
end Function

谢谢

答案1

宏语言无法访问电子表格函数,除非您花费几行来加载所需的函数。

就这里的目的而言,使用 的基本连接运算符会简单得多&。如下所示:

Case "0"
    binOut = binOut & "0000"

相关内容