Private Sub createCalButtons()
Dim intx As Integer = 0
Dim d As New DateTime(System.DateTime.Today.Year, System.DateTime.Today.Month, System.DateTime.Today.Day)
Dim currentLocation As Integer = 0
'Sun | Mon | Tue | Wed | Thu | Fri | Sat
' 0 1 2 3 4 5 6
' 7 8 9 10 11 12 13
'14 15 16 17 18 19 20
'21 22 23 24 25 26 27
'28 29 30 31 32 33 34
'35 37 37 38 39 40 41
Do Until intx = 40
If d.Day <= intx Then
Dim dDate As Date
Dim theLastDay As Integer
dDate = DateAdd(DateInterval.Month, 1, d)
dDate = Convert.ToDateTime(Month(dDate).ToString() & "/" & "1/" & Year(dDate).ToString())
dDate = DateAdd(DateInterval.Day, -1, dDate)
theLastDay = dDate.Day
If theLastDay = intx Then Exit Sub
Dim Button As New Button()
Select Case intx
Case 0
Button.Location = New Point(12, 31)
Case 1
Button.Location = New Point(122, 31)
Case 2
Button.Location = New Point(232, 31)
Case 3
Button.Location = New Point(342, 31)
Case 4
Button.Location = New Point(452, 31)
Case 5
Button.Location = New Point(562, 31)
Case 6
Button.Location = New Point(672, 31)
Case 7
Button.Location = New Point(12, 131)
Case 8
Button.Location = New Point(122, 131)
Case 9
Button.Location = New Point(232, 131)
Case 10
Button.Location = New Point(342, 131)
Case 11
Button.Location = New Point(452, 131)
Case 12
Button.Location = New Point(562, 131)
Case 13
Button.Location = New Point(672, 131)
Case 14
Button.Location = New Point(12, 231)
Case 15
Button.Location = New Point(122, 231)
Case 16
Button.Location = New Point(232, 231)
Case 17
Button.Location = New Point(342, 231)
Case 18
Button.Location = New Point(452, 231)
Case 19
Button.Location = New Point(562, 231)
Case 20
Button.Location = New Point(672, 231)
Case 21
Button.Location = New Point(12, 331)
Case 22
Button.Location = New Point(122, 331)
Case 23
Button.Location = New Point(232, 331)
Case 24
Button.Location = New Point(342, 331)
Case 25
Button.Location = New Point(452, 331)
Case 26
Button.Location = New Point(562, 331)
Case 27
Button.Location = New Point(672, 331)
Case 28
Button.Location = New Point(12, 431)
Case 29
Button.Location = New Point(122, 431)
Case 30
Button.Location = New Point(232, 431)
Case 31
Button.Location = New Point(342, 431)
Case 32
Button.Location = New Point(452, 431)
Case 33
Button.Location = New Point(562, 431)
Case 34
Button.Location = New Point(672, 431)
Case 35
Button.Location = New Point(12, 531)
Case 36
Button.Location = New Point(122, 531)
Case 37
Button.Location = New Point(232, 531)
Case 38
Button.Location = New Point(342, 531)
Case 39
Button.Location = New Point(452, 531)
Case 40
Button.Location = New Point(562, 531)
Case 41
Button.Location = New Point(672, 531)
End Select
Button.Name = "cmdCalButton" & intx
Button.Text = intx
Button.Size = New Size(104, 94)
Button.Font = New Font("Arial", 42, FontStyle.Bold)
Button.FlatStyle = FlatStyle.Flat
Button.FlatAppearance.MouseDownBackColor = ColorTranslator.FromOle(RGB(255, 128, 0))
Button.FlatAppearance.MouseOverBackColor = ColorTranslator.FromOle(RGB(255, 128, 0))
Button.BringToFront()
AddHandler Button.Click, AddressOf calButtonEvents_click
Me.Controls.Add(Button)
intx += 1
Else
intx += 1
End If
Loop
End Sub
Private Sub calButtonEvents_click(ByVal sender As Object, ByVal e As System.EventArgs)
MsgBox("test")
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call createCalButtons()
End Sub
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147: