Private Function IsLeapYear(LngY As Long) As Boolean
IsLeapYear = (LngY Mod 4 = 0 And LngY Mod 100 <> 0) Or (LngY Mod 100 = 0 And LngY Mod 400 = 0)
End Function
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, P As String, A As String
iMonth = cboMonth.ListIndex + 1
Y = cboYear.Text
'Me.TARRIVO.Text = ""
'Me.TPARTE.Text = ""
With MSFlexGrid2
RW = .MouseRow
CL = .MouseCol
If RW >= 1 And .TextMatrix(RW, CL) > "" Then
If Me.TARRIVO.Text > "" And Me.TPARTE.Text > "" Then
Me.TGG.Text = DateDiff("D", Me.TPARTE.Text, Me.TARRIVO.Text)
Me.TPARTE.Text = ""
Me.TARRIVO.Text = ""
End If
Else
Me.LDATA1.Caption = ""
End If
End With
End Sub
i need to manage only two mouse click.
for example first click insert date in ARRIVO tbox , second click insert date in PARTENZA tbox then if the two tbox are fiklled go to difference of day...
If Me.TARRIVO.Text > "" And Me.TPARTE.Text > "" Then
'number of days
Me.TGG.Text = DateDiff("D", Me.TPARTE.Text, Me.TARRIVO.Text)
Me.TPARTE.Text = ""
Me.TARRIVO.Text = ""
End If
This is not elegant, but does show how, with 2 clicks on a datepicker, you can populate two textboxes with dates and calculate the difference for the third textbox
Code:
Option Explicit
Dim numClicks As Integer
Private Sub DTPicker1_Change()
numClicks = numClicks + 1
If numClicks = 1 Then
Text1.Text = DTPicker1.Value
If Text2.Text <> "" Then
Text3.Text = DateDiff("d", CDate(Text1.Text), CDate(Text2.Text))
End If
Else
Text2.Text = DTPicker1.Value
Text3.Text = DateDiff("d", CDate(Text1.Text), CDate(Text2.Text))
numClicks = 0
End If
End Sub