67biscuits
Member
So, have a quick butchers at the code here...
on lines 44 to 48 (approx) you see a datetime.dateformat = "F". If I take that out, ignoring the Log(), the next line fails always! Why is that? I wonder
Also, same line, why is firstday ALWAYS 2, regardless of the month quiried?
What newby's blunder am I committing??? Help me please by pointing out that one small tick, comma, keystroke I have missed.
Thanks folks
quirky:
Sub createGrid(Col As Int, Row As Int)
Dim now As Long = DateTime.Now
Dim pnl As Panel
Dim spnM As Spinner
Dim spnY As Spinner
Dim gap As Int = 2dip
Dim wday As Label
pnl.Initialize("pnl")
spnM.initialize("spnM")
spnY.Initialize("spnY")
wday.Initialize("wday")
pnl.Color = xui.Color_white
pnl.Elevation = 20dip
pnlHours.AddView(pnl,40dip, 0dip, 280dip - gap, 380dip - gap)
Dim spnWidth As Int = pnl.Width / 2 - gap
Dim btnWH As Int = pnl.Width/Col
Dim btns As List
btns.Initialize
Dim days As List = Array("Su","Mo","Tu","We","Th","Fr","Sa")
'========ad the views ==============
pnl.AddView(spnM, 0dip, 0dip, spnWidth, 40dip)
pnl.AddView(spnY, spnWidth- gap , 0dip, spnWidth - gap , 40dip)
Dim d As Int = 0
Dim top As Int = 40dip
For r = 1 To Row
top = top + 40dip
For c = 0 To Col - 1
d = d + 1
Dim btn As Button
btn.Initialize("btn")
pnl.AddView(btn, c*40dip, top + gap, btnWH, btnWH)
btn.TextSize = 10
btns.Add(btn)
Next
Next
Dim aMonth As String = activeMonth
If activeMonth < 10 Then aMonth = $"0${aMonth}"$
Log($"aMonth = ${aMonth}"$)
Dim TT As String = $"${aMonth}/01/${activeYear}"$
Dim firstday As Int
DateTime.DateFormat="F"
Log($"TT: ${TT}"$)
firstday = DateTime.GetDayOfWeek(DateTime.DateParse(TT))
Log(firstday)
btns.Get(firstday).As(Button).Text = "F"
'=======fill the spots ===============
spnM.AddAll(Array As String("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))
spnY.Addall(Array As Int( 2024,2025))
spnM.SelectedIndex = (DateTime.getMonth(now)-1)
spnY.selectedindex = (DateTime.GetYear(now))
For x = 0 To 6
Dim wday As Label
wday.Initialize("wday")
pnl.AddView(wday, x * btnWH + gap, 40dip + gap, btnWH, btnWH)
wday.Text = $" ${days.get(x)}"$
Next
For x = firstday To DateUtils.NumberOfDaysInMonth(activeMonth,activeYear) + firstday
btns.Get(x).As (Button).text = (x-firstday)+1
Next
End Sub
on lines 44 to 48 (approx) you see a datetime.dateformat = "F". If I take that out, ignoring the Log(), the next line fails always! Why is that? I wonder
Also, same line, why is firstday ALWAYS 2, regardless of the month quiried?
What newby's blunder am I committing??? Help me please by pointing out that one small tick, comma, keystroke I have missed.
Thanks folks