【发布时间】:2018-03-30 13:00:11
【问题描述】:
我为 calc 编写了一个函数,用于在包含某些字符的单词之前分割一个单元格:
Function sidx(inputstr) As Integer
Dim newString As String
newString = ""
Dim last_space_idx As String
last_space_idx = 0
Dim l As Integer
'l = (inputstr.Length - 1) was ported from js on google sheets
l = Len(inputstr) - 1
For i = 0 To l
If inputstr(i) = " " Then
last_space_idx = i
End If
If ("’aeiou".Indexof( inputstr(i) ) > 0) Then
sidx = last_space_idx
End If
Next i
sidx = last_space_idx
End Function
由于某种原因,libreoffice 无法解析此内容,并抱怨括号不匹配或在最后一个 If 语句中缺少 Then。有什么想法吗?
【问题讨论】:
-
这是
vba还是vb.net??.IndexOf看起来是vb.net... -
虽然应该是
If ("’āēīōū".Indexof(inputstr(i))) > 0 Then,但将括号从> 0的外部移到内部。 -
@OrenBochman 我认为 VBA 中不存在
.IndexOf。虽然我可能错了。 -
字符串不是 VBA 中的对象。您不能在字符串文字上调用方法。此外,
EndIf应该是End If。在 Excel 中,VBA 编辑器会自动插入空格,但无论您使用什么,情况都可能不是这样。 -
@QHarr 这只是意味着您可以创建具有
IndexOf()作为方法的 some 对象——这并不意味着它是有效的 VBA这个上下文。这里是语法错误。
标签: vba libreoffice