2013-04-10 4 views
0

** VB를 처음 사용하고 받았으며 오류 9, 아래 첨자가 범위를 벗어났습니다. 오류는 아래 절차에 있음을 나타냅니다. 문제가 무엇인지 알려주세요. 나는 당신의 도움VB - 첨자가 범위를 벗어남, 오류 9

Private Sub RebuildGrid() 
    Const c_strProcedureName As String = "RebuildGrid" 
    Dim intIndex As Integer 

    On Error GoTo Error_Handler 

    For intIndex = 0 To g_intNumNucDataFields - 1 
     grdNuclides.Columns(intIndex).DataField = ga_strNucFieldName(intIndex) 
     grdNuclides.Columns(intIndex).Visible = False 

     If StrComp(ga_strNucFieldFormat(intIndex), "None", vbTextCompare) <> 0 Then 
      grdNuclides.Columns(intIndex).NumberFormat = ga_strNucFieldFormat(intIndex) 
     End If 

     grdNuclides.Columns(intIndex).Width = 1400 

     If StrComp(LCase$(ga_strNucFieldUnits(intIndex)), "none", vbTextCompare) = 0 Then 
      grdNuclides.Columns(intIndex).Caption = ga_strNucFieldTitle(intIndex) 
     Else 
      grdNuclides.Columns(intIndex).Caption = ga_strNucFieldTitle(intIndex) & _ 
      " " & vbCr & "(" & ga_strNucFieldUnits(intIndex) & ") " 
     End If 
     grdNuclides.Columns(intIndex).FooterText = "Reference" 
    Next intIndex 

    Exit Sub 
Error_Handler: 

    gud_PrgErr.Number = Err.Number 
    gud_PrgErr.Severity = 5 
    gud_PrgErr.Description = Err.Description 
    gud_PrgErr.Module = c_strModuleName 
    gud_PrgErr.Procedure = c_strProcedureName 
    Call Display_UI_Error 

End Sub 

Private Sub mnuFileExit_Click() 
    Unload Me 
End Sub 
+0

어떤 줄에서 오류가 발생합니까? 'ga_strNucFieldFormat'의 기능은 무엇입니까? – Brad

+0

우리는 볼 수없는 프로 시저 (예 :'ga_strNucFieldFormat')에 배열이있는 것 같습니다. 당신의 오류는 당신이 이러한 배열 내에 존재하지 않는 요소를 얻으려고하는 것을 제안합니다. 당신이 루프를 시작할 때'LBound'와'Ubound'를 확인하려고 시도합니다 :'For intIndex = LBound (ga_strNucFieldName) To Ubound (ga_strNucFieldName)' –

답변

0

g_intNumNucDataFields이 열 수보다 더 있지 않은지 확인합니다 (예 : grdNuclides.Columns.Count)를 주셔서 감사합니다.

또한 오류 처리를 주석 처리 한 다음 실행하여 오류에 줄 번호가 있는지 확인하십시오.

관련 문제