gpt4 book ai didi

vba - VB-下标超出范围,错误9

转载 作者:行者123 更新时间:2023-12-02 11:05:27 25 4
gpt4 key购买 nike

**我是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

最佳答案

确保g_intNumNucDataFields不高于列数(例如grdNuclides.Columns.Count)。

您也可以尝试注释掉错误处理,然后运行它以查看是否获得错误的行号。

关于vba - VB-下标超出范围,错误9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15935430/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com