这就是我所拥有的,我不知道如何更改嵌套循环以使其在IntDays数组中每天显示。
Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
Dim strMonths() As String = {
"january", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "Novemeber", "December"}
Dim intDays() As Integer = {
31, 28, 31,
30, 31, 30,
31, 31, 30,
31, 30, 31
}
For MonthCounter = 0 To strMonths.Length - 1
ls.Items.Add(strMonths(MonthCounter) & " has " & intDays(MonthCounter).ToString & " days.")
For DayCounter = 0 To intDays.Length - 1
ls.Items.Add(strMonths(MonthCounter) & " " & intDays(DayCounter))
Next
Next
End Sub
答案 0 :(得分:2)
声音就像您想要在给定月份中每天显示作为内循环的一部分。基本上1月份为1 - 31,2月份为1-28,等等......如果是,请执行以下操作
Dim total = intDays(MonthCounter)
For DayCounter = 0 To total - 1
ls.Items.Add(strMonths(MonthCounter) & " " & (DayCounter + 1))
Next
如果这不是你想要的,你可以尝试用预期的输出来修改你的问题吗?甚至不是全部,代表性的样本就足够了
答案 1 :(得分:0)
我只是想进入并声明你不必像你那样记下整月 你可以做几天相同的事情
Dim strMonths As String() = Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthNames