在 vbscript 中,我正在尝试(到目前为止没有成功)将数组作为参数传递给子:
subUnPackAArray(arrLineFieldValues)
我从 Vbscript 收到以下错误消息:
Error: Type mismatch: 'subUnPackAArray'
Code: 800A000D
Source: Microsoft VBScript runtime error
System: The data is invalid.
我将不胜感激有关在哪里寻找解决方案的任何解决方案或建议。我是 vbscript 爱好者,不是专业人士,所以请在批评时保持温和。
该数组包含以下文本:
Line 0
Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Line
Line
Line
.... etc....
从中获取文本的文件的名称是:
strFile2HarvestFromFullName = "C:\Apps\E_drive\Parameters for vbscript or python_script to harvest .txt"
我想确认子“subUnPackAArray”中没有错误(我试图将“arrLineFieldValues”作为参数传递给它)。
因此,为了确认这一点,我在行上方插入了 -- subUnPackAArray(arrLineFieldValues)
...几乎所有代码都在子“subUnPackAArray”中。
代码执行得很好,只有当 vbscript 到达该行时我才会收到错误消息:
subUnPackAArray(arrLineFieldValues)
我不知道出了什么问题。
这是我的 vbsript 程序的全部文本:' 从文本文件中读取参数
strFile2HarvestFromFullName = "C:\Apps\E_drive\Parameters for vbscript or python_script to harvest .txt"
fn_Read_text_file_lines_into_1_dimL_array(strFile2HarvestFromFullName)
'*'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'* BEGIN_Function'*' BEGIN_Function '*' BEGIN_Function '*' BEGIN_Function '*' BEGIN_Function '*' BEGIN_Function '*' BEGIN_Function '*' BEGIN_Function
'*'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function fn_Read_text_file_lines_into_1_dimL_array(fname)
Dim strFile2HarvestFromFullName
Dim objFSO
Dim objTextFile
Dim arrLineFieldValues()
Dim strText
Dim subUnPackAArray
strFile2HarvestFromFullName = fname
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(strFile2HarvestFromFullName, ForReading)
i = 0
Do Until objTextFile.AtEndOfStream
ReDim Preserve arrLineFieldValues(i)
strText = objTextFile.ReadLine
'MsgBox strText
arrLineFieldValues(i) = strText
i = i + 1
Loop
intUbound = UBound(arrLineFieldValues)
strMsgBoxMsg = ""
For i = 0 To intUbound
strMsgBoxMsg = strMsgBoxMsg & _
"arrLineFieldValues(" & i & ") = " & arrLineFieldValues(i) & vbCrLf
Next ' For i = 0 To intUbound
MsgBox "Line 45: " & vbCrLf & strMsgBoxMsg
subUnPackAArray(arrLineFieldValues)
End Function ' fn_Read_text_file_lines_into_1_dimL_array(fname)
'*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'* END_Function '*'END_Function '*'END_Function '*'END_Function '*'END_Function '*'END_Function '*'END_Function '*'END_Function '*'END_Function '*'END_Function
'*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'* BEGIN_Sub'*' BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub '*'
'*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub subUnPackAArray(strArray_OneDimensionOnly)
'
Dim strArray
'strArray = strArray_OneDimensionOnlye
intUbound = UBound(strArray_OneDimensionOnly)
strMsgBoxMsg = ""
For i = 0 To intUbound
strMsgBoxMsg = strMsgBoxMsg & _
"strArray(" & i & ") = " & strArray_OneDimensionOnly(i) & vbCrLf
Next ' For i = 0 To intUbound
MsgBox "Line 25: " & vbCrLf & strMsgBoxMsg
End Sub ' subUnPackAArray()
'*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'* END_Sub '*'END_Sub '*'END_Sub '*'END_Sub '*'END_Sub '*'END_Sub '*'END_Sub '*'END_Sub '*'END_Sub '*'END_Sub '*'END_Sub '*'END_Sub '*'END_Sub
'*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''