vbscript函数未正确执行

vbscript函数未正确执行,vbscript,Vbscript,我试图创建一个基本的vbscript程序,作为一个待办事项列表。它将具有向数组中添加待办事项、修改事项、删除事项和生成事项的功能。我无法让程序正确执行插入待办事项。它在choice=“1”的“我的if”语句中显示错误 此外,任何关于我的代码的其他建议都将不胜感激 Option Explicit dim choice dim fn dim fh dim num_items dim new_item Dim to_do_list_array, objSHL to_do_list_array

我试图创建一个基本的vbscript程序,作为一个待办事项列表。它将具有向数组中添加待办事项、修改事项、删除事项和生成事项的功能。我无法让程序正确执行插入待办事项。它在choice=“1”的“我的if”语句中显示错误

此外,任何关于我的代码的其他建议都将不胜感激

Option Explicit
dim choice
dim fn
dim fh    
dim num_items
dim new_item
Dim to_do_list_array, objSHL
to_do_list_array = Array()


fn = InputBox("enter text file to open: ", "open text file")
set fh =CreateObject("Scripting.FileSystemObject").OpenTextFile(fn,8,true)


Do
choice=InputBox("Administrator To-do List " & chr(13) &  "'1' - Insert new         
to-to item, " & chr(13) & "'2'- Modify existing to-do item, " & chr(13) &     
"'3'- Remove existing to-do item," & chr(13) & "'4' - Generate list of to-do 
items," & chr(13) & "'5' - quit", "Administrator To-do List") 

If choice= "" Then MsgBox "You must enter a numeric value.", 48, "Invalid         
Entry"    
If choice= "1" Then AddtoArray(CurrentArray)
If choice= "2" Then document.write("test")
If choice= "3" Then document.write("test")
If choice= "4" Then document.write("test")
If choice= "5" Then WScript.quit()
Loop 

Function AddtoArray(CurrentArray)
to_do_list_array = AddtoArray(to_do_list_array)
Dim Value
If IsArray(CurrentArray) Then
Do
Value = InputBox(Join(CurrentArray,vbLf),"Add to your array.")
ReDim Preserve CurrentArray(UBound(CurrentArray) + 1)
CurrentArray(UBound(CurrentArray)) = Value
Loop Until Value = ""
End If
AddtoArray = CurrentArray
End Function

fh.close
对我来说,在这个代码中

to_do_list_array = AddtoArray(to_do_list_array) 

fn = InputBox("enter text file to open: ", "open text file")
首先执行第一行,
AddtoArray
函数的作用是

Function AddtoArray(CurrentArray)
Dim Value
    If IsArray(CurrentArray) Then
        Do
            Value = InputBox(Join(CurrentArray,vbLf),"Add to your array.")
....

可能第一行不应该在原来的位置

谢谢,我移动了那一行,程序按顺序执行。但是,现在当我尝试调用函数choice=“1”insert时,它没有正确执行,它遇到了错误error@matthewarnold,没有关于错误是什么的更多信息,我将指出函数
AddtoArray
中的第一行是对自身的调用。尝试删除此行。