VB6到VS2015升级>循环错误

时间:2015-11-05 15:35:34

标签: .net visual-studio vb6

我最近被聘请为一家公司修改一些代码,但是对于编码很新,我遇到了一个问题,想知道如何修复从Visual Basic 6.0升级到Visual Studio 2015时给出的错误。这是错误:

'GoTo UP_NUM'无效,因为'UP_NUM'位于不包含此语句的'With'语句中。

以下是我正在使用的函数/代码的片段:

    Function UpdateItemFileNum() As Boolean
   Dim iNumErrorsThrown, iNumErrorsAllowed As Short
   Dim lErrorNum As Integer
   Dim sProcedureName, lFunctionName, lErrorDes, currTask As String 'Intra-Procedure tag
   '***Stop Error handler Variables*****
   Dim returnValue As Boolean
   'UPGRADE_WARNING: Arrays in structure baseRS may need to be initialized before they can be used. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="814DF224-76BD-4BB4-BFFB-EA359CB9FC48"'
   Dim baseRS As dao.Recordset
   Dim db As dao.Database
   Dim lvCMax As Integer

   lFunctionName = cvconClassName & ":.UpdateItemFileNum!"
   currTask = "Start Function" 'establish default position
   returnValue = True 'establish default position
   On Error GoTo ERR_HANDLER


   db = DAODBEngine_definst.OpenDatabase(gpConversionDb.Name, , False)

   '<obtain the max
   baseRS = db.OpenRecordset("Select MAX(VAL(NUM)) FROM ItemFile")
   lvCMax = 50000
   lvCMax = baseRS.Fields(0).Value
   Call gpConversionDb.Execute("Update ItemFile Set Num = val(num) + " & lvCMax)
   MAX_ITEM_NUM = 1
   '   >

   baseRS = db.OpenRecordset("ItemFile", dao.RecordsetTypeEnum.dbOpenTable)
   With baseRS
       Do While Not.EOF
           MAX_ITEM_NUM = MAX_ITEM_NUM + 1
           .Edit()
    UP_NUM:
           .Fields("NUM").Value = MAX_ITEM_NUM
           .Update()
           .MoveNext() 'cycle next record
       Loop
   End With 'baseRS

    PROC_EXIT:  'Close Resources

   If Not baseRS Is Nothing Then
       baseRS.Close()
       'UPGRADE_NOTE: Object baseRS may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
       baseRS = Nothing
   End If

   UpdateItemFileNum = returnValue
   Exit Function 'Exit here

    ERR_HANDLER:
   returnValue = False
   With Err
       lErrorNum = Err.Number
       lErrorDes = Err.Description
       sProcedureName = .Source
   End With
   iNumErrorsThrown = iNumErrorsThrown + 1 'talley errors
   If lErrorNum = 3022 Then
       MAX_ITEM_NUM = MAX_ITEM_NUM + 1
       currTask = "Try up num"
       gjLog__LogEntry(jLogEnumEvents.errror, lFunctionName & sProcedureName & " ERROR#:" & lErrorNum, lErrorDes, , "<", "Task", currTask, "@@")
       Resume UP_NUM
   End If
   If iNumErrorsThrown<iNumErrorsAllowed Then 'When exceeded exit to avoid infinite loops
       gjLog__LogEntry(jLogEnumEvents.errror, lFunctionName & sProcedureName & " ERROR#:" & lErrorNum, lErrorDes, , "<", "Task", currTask, "@@")
       Resume Next
   Else
       'ask errordecision?
       gjLog__LogEntry(jLogEnumEvents.errror, lFunctionName & sProcedureName & " ERROR#:=" & lErrorNum, "REACHED_MAX_ERRORS:=" & lErrorDes, , "<", iNumErrorsThrown & " Thrown", iNumErrorsAllowed & " Max", "Task:=", currTask, "@@")
       Resume PROC_EXIT
   End If
       End Function

非常感谢任何/所有帮助!

0 个答案:

没有答案