为什么代理不会移动到下一行文本
Why wont agent move to next line of text
我正在创建一个代理程序,它将遍历从文本文件读入的 Lotus Notes 文档 ID 列表。文本文件逐行保存文档 ID,每行后没有空格,最后一个条目后也没有多余的行。但是我的代理只会处理文本文件中的第一行,而不会移动到下一行。这是为什么?
在我编写遍历视图的循环之前,MsgBox 输出了每一行。
Sub Initialize
Dim viewAllContracts As NotesView
Dim requestDoc1 As NotesDocument
Dim filenum As Integer
Dim filename As String
Dim conStatus As Variant
Dim strLineValue As String
Dim checkId As Variant
Set s = New NotesSession
Set db = s.CurrentDatabase
filenum% = FreeFile()
filename$ = "C:\ContractIdtoComplete.txt"
Open filename$ For Input As filenum%
Set viewAllContracts = db.GetView("Contracts \ All By Year")
Set requestDoc1 = viewAllContracts.GetFirstDocument
While Not EOF(filenum%) ' Read until end of file.
Line Input #filenum%, strLineValue$
Do Until requestDoc1 Is Nothing
checkId = requestDoc1.getitemvalue("conContractId")
conStatus = requestDoc1.getitemvalue("conContractStatus")
If strLineValue = CStr(checkId(0)) Then
If CStr(conStatus(0)) = "Open" Then
MsgBox "Found " & strLineValue
Call requestDoc1.ReplaceItemValue("conContractStatus", "Completed")
Call requestDoc1.Save(True, True)
End If
End If
Set requestDoc1 = viewAllContracts.Getnextdocument(requestDoc1)
Loop
Wend
Close filenum%
End Sub
在第一个 while 循环之后,您的 requestDoc1 为 Nothing。这就是为什么文本文件的下一行没有任何反应。
放行
Set requestDoc1 = viewAllContracts.GetFirstDocument
行后
Line Input #filenum%, strLineValue$
然后它将适用于所有文本文件行。
我正在创建一个代理程序,它将遍历从文本文件读入的 Lotus Notes 文档 ID 列表。文本文件逐行保存文档 ID,每行后没有空格,最后一个条目后也没有多余的行。但是我的代理只会处理文本文件中的第一行,而不会移动到下一行。这是为什么?
在我编写遍历视图的循环之前,MsgBox 输出了每一行。
Sub Initialize
Dim viewAllContracts As NotesView
Dim requestDoc1 As NotesDocument
Dim filenum As Integer
Dim filename As String
Dim conStatus As Variant
Dim strLineValue As String
Dim checkId As Variant
Set s = New NotesSession
Set db = s.CurrentDatabase
filenum% = FreeFile()
filename$ = "C:\ContractIdtoComplete.txt"
Open filename$ For Input As filenum%
Set viewAllContracts = db.GetView("Contracts \ All By Year")
Set requestDoc1 = viewAllContracts.GetFirstDocument
While Not EOF(filenum%) ' Read until end of file.
Line Input #filenum%, strLineValue$
Do Until requestDoc1 Is Nothing
checkId = requestDoc1.getitemvalue("conContractId")
conStatus = requestDoc1.getitemvalue("conContractStatus")
If strLineValue = CStr(checkId(0)) Then
If CStr(conStatus(0)) = "Open" Then
MsgBox "Found " & strLineValue
Call requestDoc1.ReplaceItemValue("conContractStatus", "Completed")
Call requestDoc1.Save(True, True)
End If
End If
Set requestDoc1 = viewAllContracts.Getnextdocument(requestDoc1)
Loop
Wend
Close filenum%
End Sub
在第一个 while 循环之后,您的 requestDoc1 为 Nothing。这就是为什么文本文件的下一行没有任何反应。
放行
Set requestDoc1 = viewAllContracts.GetFirstDocument
行后
Line Input #filenum%, strLineValue$
然后它将适用于所有文本文件行。