why AUGUST init on fryday!!!

User avatar
sal21
PlatinumLounger
Posts: 4495
Joined: 26 Apr 2010, 17:36

why AUGUST init on fryday!!!

Post by sal21 »

why AUGUST init on fryday!!!
You do not have the required permissions to view the files attached to this post.

User avatar
SpeakEasy
5StarLounger
Posts: 616
Joined: 27 Jun 2021, 10:46

Re: why AUGUST init on fryday!!!

Post by SpeakEasy »

Mainly because the code is a mess. Finding the last and first days can be done in a line, no need for the multiline functions or checking for leap ears. That being said they do look like they get the right values. But how those values are then used to figure out where to print the numbers (both in the DrawDays and in the mousemove routine) is inconsistent and incorrect.

Here's a modification of DrawDays(still not great code) that at least puts the dates in the right cells:

Code: Select all

Private Sub DrawDays()
    Dim I As Long
    Dim iRow As Integer
    Dim iMonth As Integer
    Dim sText As String

    On Local Error Resume Next

    If Not mfLoaded Then Exit Sub

    'Get selected month
    iMonth = cboMonth.ListIndex + 1

    iRow = 1

    For I = DateSerial(cboYear.Text, iMonth, 1) To DateSerial(cboYear.Text, iMonth + 1, 0) 'nDate + iLast - 1
        sText = Format$(Day(I), "0")
        picCal.CurrentY = (Dy * iRow) + (0.5 * (Dy - picCal.TextHeight(sText)))
        picCal.CurrentX = dX * (Weekday(I, vbMonday) - 1) + (0.5 * (dX - picCal.TextWidth(sText)))
        picCal.Print sText
        iRow = iRow - (Weekday(I) = vbSunday)
    Next

End Sub
Note that this should give you enough info to make a similar modification the MouseMove event

User avatar
sal21
PlatinumLounger
Posts: 4495
Joined: 26 Apr 2010, 17:36

Re: why AUGUST init on fryday!!!

Post by sal21 »

SpeakEasy wrote:
31 Jul 2024, 23:28
Mainly because the code is a mess. Finding the last and first days can be done in a line, no need for the multiline functions or checking for leap ears. That being said they do look like they get the right values. But how those values are then used to figure out where to print the numbers (both in the DrawDays and in the mousemove routine) is inconsistent and incorrect.

Here's a modification of DrawDays(still not great code) that at least puts the dates in the right cells:

Code: Select all

Private Sub DrawDays()
    Dim I As Long
    Dim iRow As Integer
    Dim iMonth As Integer
    Dim sText As String

    On Local Error Resume Next

    If Not mfLoaded Then Exit Sub

    'Get selected month
    iMonth = cboMonth.ListIndex + 1

    iRow = 1

    For I = DateSerial(cboYear.Text, iMonth, 1) To DateSerial(cboYear.Text, iMonth + 1, 0) 'nDate + iLast - 1
        sText = Format$(Day(I), "0")
        picCal.CurrentY = (Dy * iRow) + (0.5 * (Dy - picCal.TextHeight(sText)))
        picCal.CurrentX = dX * (Weekday(I, vbMonday) - 1) + (0.5 * (dX - picCal.TextWidth(sText)))
        picCal.Print sText
        iRow = iRow - (Weekday(I) = vbSunday)
    Next

End Sub
Note that this should give you enough info to make a similar modification the MouseMove event
tks bro.
but not mine code.

User avatar
sal21
PlatinumLounger
Posts: 4495
Joined: 26 Apr 2010, 17:36

Re: why AUGUST init on fryday!!!

Post by sal21 »

SpeakEasy wrote:
31 Jul 2024, 23:28
Mainly because the code is a mess. Finding the last and first days can be done in a line, no need for the multiline functions or checking for leap ears. That being said they do look like they get the right values. But how those values are then used to figure out where to print the numbers (both in the DrawDays and in the mousemove routine) is inconsistent and incorrect.

Here's a modification of DrawDays(still not great code) that at least puts the dates in the right cells:

Code: Select all

Private Sub DrawDays()
    Dim I As Long
    Dim iRow As Integer
    Dim iMonth As Integer
    Dim sText As String

    On Local Error Resume Next

    If Not mfLoaded Then Exit Sub

    'Get selected month
    iMonth = cboMonth.ListIndex + 1

    iRow = 1

    For I = DateSerial(cboYear.Text, iMonth, 1) To DateSerial(cboYear.Text, iMonth + 1, 0) 'nDate + iLast - 1
        sText = Format$(Day(I), "0")
        picCal.CurrentY = (Dy * iRow) + (0.5 * (Dy - picCal.TextHeight(sText)))
        picCal.CurrentX = dX * (Weekday(I, vbMonday) - 1) + (0.5 * (dX - picCal.TextWidth(sText)))
        picCal.Print sText
        iRow = iRow - (Weekday(I) = vbSunday)
    Next

End Sub
Note that this should give you enough info to make a similar modification the MouseMove event
BRO...
now i test new code with msflexgrid.

the project is a reservation room

my prob, is:

if i cleck one time on msflexgrid i need to insert the date in tbox ARRIVO, the second click on msflexgrisd if for tbox PARTENZA.

HOW TO CHECK THIS CPNIDTIO?

In effect i need to rtestrict only two click....

Code: Select all


Private Sub MSFlexGrid2_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)

Dim CL As Integer, RW As Integer, iMonth As Integer

    iMonth = cboMonth.ListIndex + 1
    y = cboYear.Text

    With MSFlexGrid2

        RW = .MouseRow
        CL = .MouseCol

        If RW >= 1 And .TextMatrix(RW, CL) > "" Then
            Me.TARRIVO.Text = Format(.TextMatrix(RW, CL) & "/" & iMonth & "/" & y, "DD/MM/YYYY")
        Else
            Me.TARRIVO.Text = ""
        End If

    End With

End Sub
You do not have the required permissions to view the files attached to this post.

User avatar
SpeakEasy
5StarLounger
Posts: 616
Joined: 27 Jun 2021, 10:46

Re: why AUGUST init on fryday!!!

Post by SpeakEasy »

As I recall, you use VB6 - and VB6 includes both a Calendar control and a DatePicker control (the latter of which seems ideal for what you are trying to do). Why reinvent the wheel?