【发布时间】:2015-10-18 01:40:17
【问题描述】:
我正在尝试创建充当待办事项列表的基本 vbscript 程序。它将具有将待办事项添加到数组、修改项目、删除项目和生成项目的功能。我无法让程序正确执行插入待办事项。它在我的 if 语句中显示一个错误,用于选择=“1”
此外,非常感谢您对我的代码提出任何其他建议!
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
【问题讨论】:
标签: vbscript