[RESOLVED] Error that says : Subscript out of range...
Hi,
I am getting an error: "Subscript out of range" and highlights the following line:
VB Code:
dbgAutomobiles.Columns(i).Width = 0
I have 47 fields in total.
The following is the code:
VB Code:
Private Sub Datagridcolumns()
Dim i As Integer
dbgAutomobiles.Columns(0).Width = 0
dbgAutomobiles.Columns(1).Width = 3025
dbgAutomobiles.Columns(2).Width = 1000
dbgAutomobiles.Columns(3).Width = 900
For i = 4 To dbgAutomobiles.Columns.Count
dbgAutomobiles.Columns(i).Width = 0
Next
End Sub
Regards.
Seema_s
Re: Error that says : Subscript out of range...
The columns have a 0-based index so you need:
VB Code:
For i = 4 To dbgAutomobiles.Columns.Count - 1
Re: Error that says : Subscript out of range...
Quote:
Originally Posted by bushmobile
The columns have a 0-based index so you need:
VB Code:
For i = 4 To dbgAutomobiles.Columns.Count - 1
Thanks it works fine.