Imports System.Text
Module Module1
Sub Main()
Dim info As New Dictionary(Of String, Detail)
Dim i = 0
i += 1
info.Add(i.ToString, setD200())
i += 1
info.Add(i.ToString, setD100())
i += 1
info.Add(i.ToString, setD200())
Dim inputStart = "2020/10"
Dim inputEnd = "2021/01"
Dim st = Date.Parse(inputStart)
Dim en = Date.Parse(inputEnd)
Dim inputPrice = 150
Dim inputMonths As New List(Of Integer)
Dim kikan = DateDiff(DateInterval.Month, st, en)
For i = 0 To kikan
inputMonths.Add(Month(st.AddMonths(i)))
Next
Dim isBreak = False
Dim color As String
For Each de As Detail In info.Values
'low
For Each input As Integer In inputMonths
If de.months.Contains(input) AndAlso inputPrice < de.price Then
isBreak = True
color = "blue"
End If
Next
If isBreak Then
Exit For
Else
'high
For Each input As Integer In inputMonths
If de.months.Contains(input) AndAlso inputPrice > de.price Then
color = "red"
End If
Next
End If
Next
Console.WriteLine(color)
End Sub
Private Function setD100() As Detail
Dim d1 As New Detail
d1.startMonth = "2020/10"
d1.endMonth = "2021/02"
d1.price = 100
d1.cnt1 = 0 '10
d1.cnt2 = 1 '11
d1.cnt3 = 1 '12
d1.cnt4 = 1 '1
d1.cnt5 = 0 '2
d1.cnt6 = 0 '3
d1.cnt7 = 0 '4
d1.cnt8 = 0 '5
d1.cnt9 = 0 '6
d1.cnt10 = 0 '7
d1.cnt11 = 0 '8
d1.cnt12 = 0 '9
Return d1
End Function
Private Function setD200() As Detail
Dim d1 As New Detail
d1.startMonth = "2020/10"
d1.endMonth = "2021/02"
d1.price = 200
d1.cnt1 = 1 '10
d1.cnt2 = 0 '11
d1.cnt3 = 0 '12
d1.cnt4 = 0 '1
d1.cnt5 = 1 '2
d1.cnt6 = 0 '3
d1.cnt7 = 0 '4
d1.cnt8 = 0 '5
d1.cnt9 = 0 '6
d1.cnt10 = 0 '7
d1.cnt11 = 0 '8
d1.cnt12 = 0 '9
Return d1
End Function
Public Class Detail
Public startMonth As String
Public endMonth As String
Public price As Long
Public cnt1 As Long
Public cnt2 As Long
Public cnt3 As Long
Public cnt4 As Long
Public cnt5 As Long
Public cnt6 As Long
Public cnt7 As Long
Public cnt8 As Long
Public cnt9 As Long
Public cnt10 As Long
Public cnt11 As Long
Public cnt12 As Long
Public all As String
Public ReadOnly Property months() As List(Of Integer)
Get
Dim monthList As New List(Of Integer)
Dim sm = Date.Parse(Me.startMonth)
If cnt1 > 0 Then
monthList.Add(Month(sm.AddMonths(0)))
End If
If cnt2 > 0 Then
monthList.Add(Month(sm.AddMonths(1)))
End If
If cnt3 > 0 Then
monthList.Add(Month(sm.AddMonths(2)))
End If
If cnt4 > 0 Then
monthList.Add(Month(sm.AddMonths(3)))
End If
If cnt5 > 0 Then
monthList.Add(Month(sm.AddMonths(4)))
End If
If cnt6 > 0 Then
monthList.Add(Month(sm.AddMonths(5)))
End If
If cnt7 > 0 Then
monthList.Add(Month(sm.AddMonths(6)))
End If
If cnt8 > 0 Then
monthList.Add(Month(sm.AddMonths(7)))
End If
If cnt9 > 0 Then
monthList.Add(Month(sm.AddMonths(8)))
End If
If cnt10 > 0 Then
monthList.Add(Month(sm.AddMonths(9)))
End If
If cnt11 > 0 Then
monthList.Add(Month(sm.AddMonths(10)))
End If
If cnt12 > 0 Then
monthList.Add(Month(sm.AddMonths(11)))
End If
Return monthList
End Get
End Property
End Class
End Module
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
00