我想检查空数组.Google给了我各种解决方案,但没有任何效果 也许我没有正确应用它们.
Function GetBoiler(ByVal sFile As String) As String
'Email Signature
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.ReadAll
ts.Close
End Function
Dim FileNamesList As Variant, i As Integer
' activate the desired startfolder for the filesearch
FileNamesList = CreateFileList("*.*", False) ' Returns File names
' performs the filesearch, includes any subfolders
' present the result
' If there are Signatures then populate SigString
Range("A:A").ClearContents
For i = …Run Code Online (Sandbox Code Playgroud) 将未扩展的数组传递给VB6的Ubound函数将导致错误,因此我想在检查其上限之前检查它是否已被标注尺寸.我该怎么做呢?
很抱歉问这样一个基本问题,但这让我很生气......
VBA中的哪个函数返回数组中的元素数...即当数组为空时它将返回0?
我不能用UBound做这个,因为它在一个空数组上调用时抛出一个错误,我不能相信通过使用OnError来首先确定它是否为空的方式来做到这一点......就像在论坛上建议的那样!array.Length抱怨一个糟糕的限定符或其他东西.
我真的需要这样做:
dim termAry() as String
populate termAry
...
private sub populate(terms() as String)
redim preserve terms(terms.Length) ' Redim takes ubound for array size
terms(ubound(terms)) = "something really annoying"
end sub
Run Code Online (Sandbox Code Playgroud)
PS任何良好的链接到一个简洁的VBA语言和函数参考将是最有用的... MSDN似乎真的很模糊!