この問題でテーブルを生成するfor文から飛び出す場所で実行し続けると、3時間のうちのより良い部分をコードに渡しています。私は間違っていることを見つけることができないので、もう一組の目が必要だと思います。私のコードを実行しているときに引き続きargumentOutOfRangeExceptionsを取得するvb.net
Shared Function DrawGrid() As TableLayoutPanel
Dim dayNames As New ArrayList
dayNames.Add("Monday")
dayNames.Add("Tuesday")
dayNames.Add("Wednesday")
dayNames.Add("Thursday")
dayNames.Add("Friday")
dayNames.Add("Saturday")
dayNames.Add("Sunday")
Dim hour As Integer = 8
Dim minute As Integer = 0
Dim timeType As String = "AM"
Dim dayLength As Integer = 12
Dim timetable As New TableLayoutPanel
timetable.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset
'Loops through days one at a time this creates the labels and adds them for reference by the user but is not needed for the timetable creation
For days As Integer = 0 To 7
timetable.ColumnCount += 1
timetable.RowCount += 1
If days > 0 Then
Dim NamePos As New TableLayoutPanelCellPosition(days, 0)
Dim lblDay As New Label
lblDay.Text = CStr(dayNames.Item(days))
timetable.SetCellPosition(lblDay, NamePos)
timetable.Controls.Add(lblDay)
End If
For time As Integer = 0 To dayLength
Dim rowPos As New TableLayoutPanelCellPosition(days, time)
Dim lblTime As New Label
Dim timeString As String
timetable.RowCount += 1
If days = 0 Then
minute += 6
If minute = 6 Then
minute = 0
hour += 1
End If
If hour = 13 Then
hour = 1
timeType = "PM"
End If
timeString = "Time is " & hour & ":" & minute & "0 " & timeType
lblTime.Text = timeString
timetable.SetCellPosition(lblTime, rowPos)
timetable.Controls.Add(lblTime)
timetable.Visible = True
End If
Next
Next
timetable.GrowStyle = TableLayoutPanelGrowStyle.AddColumns
timetable.AutoSize = True
MessageBox.Show("Working")
Return timetable
End Function
DAYNAMEから始まるので、私は、私は範囲例外のうちを取得します(5)myarrayのにアクセスしようとした場合、5つの項目がありますが、あなたそれを8回反復しているので、例外が発生しています。 – squelos