我有一个看起来像这样的潜艇:
Sub open_esy(filename, p As String, p1 As Integer)
Dim fileLocation As String
Dim iFileNum As Integer, findblank
Dim letter_temp0 As String, letter0 As String, letter1 As String
Dim i As Integer
Dim j As Integer
i = 16
If Dir("\\Tecan3\output\" & filename & "*esy") <> "" Then
fileLocation = "\\Tecan3\output\" & Dir("\\Tecan3\output\" & filename & "*esy")
ElseIf Dir("\\Tecan_2\output on tecan 2\" & filename & "*esy") <> "" Then
fileLocation = "\\Tecan_2\output on tecan 2\" & Dir("\\Tecan_2\output on tecan 2\" & filename & "*esy")
ElseIf Dir("\\Tecan1\tecan #1 output\" & filename & "*esy") <> "" Then
fileLocation = "\\Tecan1\tecan #1 output\" & Dir("\\Tecan1\tecan #1 output\" & filename & "*esy")
Else
MsgBox "file " & filename & "not found"
Exit Sub
End If
'open the batch file
''''old iFileNum = FreeFile()
''''old Open fileLocation For Input As #1
''''old Do While Not EOF(iFileNum)
''''old Line Input #iFileNum, stext
Dim fso As New FileSystemObject
Dim fld As Folder
Dim ts As textstream
Set ts = fso.OpenTextFile(fileLocation, ForReading)
While Not ts.AtEndOfStream
stext = ts.ReadLine
letter0 = Mid(stext, 1, 3)
If letter0 <> "A01" And letter0 <> "B01" And letter0 <> "C01" And letter0 <> "D01" And letter0 <> "E01" And letter0 <> "F01" And letter0 <> "G01" And letter0 <> "H01" And letter0 <> "I01" Then
'letter1 = Mid(stext, 7, InStr(8, stext, " ") - 7)
letter1 = Mid(stext, 7, InStr(8, stext, " ") - InStr(1, stext, " ") - 3)
Windows("Batch_XXXX revised.xlsm").Activate
Call ProcessVialPosition(letter0, i)
Cells(i, 3) = letter1
i = i + 1
End If
Wend
ts.Close
''''old Loop
''''old Close #1
Cells(2, 2) = filename
Cells(1, 2) = p
Cells(1, 4) = p1
save_template ("\\Centos5\ls-data\Interface\TF1\THC worklists\" & filename & "_THC" & ".txt")
End Sub出于某种原因,它在看似随机的点上存在
如何捕获它存在的位置,以及如何捕获错误?
发布于 2010-07-13 23:53:05
您是否在询问如何跟踪看似未被引发的错误?如果是这样,要禁用IDE中的所有错误处理,请单击“工具”->“选项”->“常规”->“中断所有错误”
如果失败,您将需要设置一个breakpoint and step throught the code。
发布于 2010-07-13 23:48:15
您需要一些错误处理代码!
Sub open_esy(filename, p As String, p1 As Integer)
On Error Goto Err_open_esy
... your sub here ...
Exit_open_esy:
Exit Sub
Err_open_esy:
... your error handling code here ...
... you can grab line numbers too if you insert them above ...
MyUniversalErrorHandler(Err.Number, Err.Description, Erl)
'Erl is the error line number from the above sub/function
End Subhttps://stackoverflow.com/questions/3238853
复制相似问题