数组是否包含数据
我在Excel VBA编程。
我有一个文件,我打开一个资源pipe理器窗口,并select一个或多个文件,并将这些文件的名称返回到一个数组。
我需要检查数组是否填充。 我试过, if FileNames(1) <> "" Then
,如果在数组中有东西的工作。 但是当数组为空时,我得到一个type mismatch
的错误。 如果我尝试If FileNames <> False Then
,当数组中没有任何东西,但是当数组中有东西给我的type mismatch
错误。 我有像Dim FileNames
一样的正常variables数组,但我已经尝试Dim FileNames() as String
也没有成功。 是否select文件我得到type mismatch
错误。 这里是我得到的代码:
sub GetUserInfo() Dim FileNames FileNames = Select_File_Or_Files_Windows 'This opens the Explorer window and allows you to pick multiple files If FileNames(1) <> "" Then 'Do something Else 'Do the last thing End If End Sub
这是一个变种,尝试
If IsArray(FileNames) Then...