Option Explicit On
Option Strict On
Public Class workschedule
Public Sub Start()
Dim choice As Integer = -1
While (choice <> 0)
WriteMenuText()
choice = Convert.ToInt32(Console.ReadLine)
Select Case choice
Case 0
Case 1
Week()
Exit Select
Case 2
Nights()
End Select
End While
End Sub
Public Sub WriteMenuText()
Console.WriteLine("-------------------------------------------------------")
Console.WriteLine(" Work schedule ")
Console.WriteLine("-------------------------------------------------------")
Console.WriteLine(" Weekend to work :1")
Console.WriteLine(" Nights to work :2")
Console.WriteLine(" Exit :0")
Console.WriteLine("-------------------------------------------------------")
Console.Write("Your choice ")
End Sub
Private Sub Week()
Dim count As Integer = 52
Dim p As Integer = 0
Const cols As Integer = 6
Dim montera As String = ""
For i As Integer = 6 To count Step 3
montera += [String].Format("{1,2}", i)
p += 1
If (p >= cols) AndAlso (p Mod cols = 0) Then
Console.WriteLine(montera)
montera = ""
End If
Next
Console.WriteLine(montera)
Console.WriteLine("-------------------------------------------------------")
End Sub
Private Sub Nights()
Dim count As Integer = 52
Dim p As Integer = 0
Const cols As Integer = 6
Dim montera As String = ""
For i As Integer = 1 To count Step 6
montera += [String].Format("{0,10} {1,2}", i)
p += 1
If (p >= cols) AndAlso (p Mod cols = 0) Then
Console.WriteLine(montera)
montera = ""
End If
Next
Console.WriteLine(montera)
Console.WriteLine("-------------------------------------------------------")
End Sub
End Class
i get a error on this line montera += [String].Format("{0,10} {1,2}", i) Index (zero based) must be greater than or equal to zero and less than the size of the argument list. what do i need to change so it can work?
i want it to look like this in week
6 9 12 15 18 21
24 and so on