Ans*_*Ans 3 excel vba excel-vba
我正在尝试在字符串中获得一些字符出现.它应该工作,但事实并非如此.
Function countLetter(letter As String, secretWord As String)
MsgBox (Split(secretWord, letter).Length)
countLetter = Split(secretWord, letter).Length - 1
End Function
Run Code Online (Sandbox Code Playgroud)
这有什么不对?
小智 7
Split没有.Length财产.使用UBound用于阵列中的元件的从零开始计数.
Function countLetter(letter As String, secretWord As String)
MsgBox UBound(Split(secretWord, letter)) + 1
countLetter = UBound(Split(secretWord, letter))
End Function
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
490 次 |
| 最近记录: |