C McHale wrote: | |
|
Hi,
Can I ask what you are wanting to calculate in the btnCalculate SUB please?
Are you trying to add the days Saturday through to Friday as text to a listbox? If so why?
I would tend to use two dateTimePicker controls for the startDate and endDate respectively.
I could do a fair bit of the code for you, but I don't think I can do the database interaction part, sorry.
Delete this bit.
Public
Class Form1
End
Class
Now PASTE this lot in.
Do not worry how it works.
I am creating the controls and adding them to the FORM at run-time,
although you do not have to do this and your code will look shorter.
It is my suggested starting point however.
If you start with a similiar layout though, Label1 is the top label, Label2 the lower label.
I have a btnCalculate and two DateTimePicker controls;
- DateTimePicker1 and
- DateTimePicker2
Public
Class Form1Private startDate, endDate AsDate
FriendWithEvents DateTimePicker1 As System.Windows.Forms.DateTimePicker
FriendWithEvents DateTimePicker2 As System.Windows.Forms.DateTimePicker
FriendWithEvents btnCalculate As System.Windows.Forms.Button
FriendWithEvents Label1 As System.Windows.Forms.Label
FriendWithEvents Label2 As System.Windows.Forms.Label
PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
Me.DateTimePicker1 = New System.Windows.Forms.DateTimePicker
Me.DateTimePicker2 = New System.Windows.Forms.DateTimePicker
Me.btnCalculate = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'DateTimePicker1'Me.DateTimePicker1.Location = New System.Drawing.Point(70, 68)Me.DateTimePicker1.Name = "DateTimePicker1"Me.DateTimePicker1.Size = New System.Drawing.Size(200, 20)Me.DateTimePicker1.TabIndex = 0''DateTimePicker2'Me.DateTimePicker2.Location = New System.Drawing.Point(70, 151)Me.DateTimePicker2.Name = "DateTimePicker2"Me.DateTimePicker2.Size = New System.Drawing.Size(200, 20)Me.DateTimePicker2.TabIndex = 1''btnCalculate'Me.btnCalculate.Location = New System.Drawing.Point(195, 231)Me.btnCalculate.Name = "btnCalculate"Me.btnCalculate.Size = New System.Drawing.Size(75, 23)Me.btnCalculate.TabIndex = 2Me.btnCalculate.Text = "Calculate"Me.btnCalculate.UseVisualStyleBackColor = True''Label1'Me.Label1.AutoSize = TrueMe.Label1.BackColor = System.Drawing.Color.WhiteMe.Label1.Location = New System.Drawing.Point(67, 27)Me.Label1.Name = "Label1"Me.Label1.Size = New System.Drawing.Size(164, 13)Me.Label1.TabIndex = 3Me.Label1.Text = "Select the StartDate here please."''Label2'Me.Label2.AutoSize = TrueMe.Label2.BackColor = System.Drawing.Color.WhiteMe.Label2.Location = New System.Drawing.Point(67, 114)Me.Label2.Name = "Label2"Me.Label2.Size = New System.Drawing.Size(161, 13)Me.Label2.TabIndex = 4Me.Label2.Text = "Select the EndDate here please."''Form1'Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.FontMe.ClientSize = New System.Drawing.Size(292, 266)Me.Controls.Add(Me.Label2)Me.Controls.Add(Me.Label1)Me.Controls.Add(Me.btnCalculate)Me.Controls.Add(Me.DateTimePicker2)Me.Controls.Add(Me.DateTimePicker1)Me.Name = "Form1"Me.Text = "Form1"Me.ResumeLayout(False)Me.PerformLayout()Label2.Hide()
DateTimePicker2.Hide()
EndSub
PrivateSub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
startDate = DateTimePicker1.Value
DateTimePicker2.MinDate = startDate
Label2.Show()
DateTimePicker2.Show()
MessageBox.Show(
"Now choose the endDate please.")EndSub
PrivateSub DateTimePicker2_ValueChanged(ByVal sender AsObject, ByVal e As System.EventArgs) Handles DateTimePicker2.ValueChanged
endDate = DateTimePicker2.Value
EndSub
PrivateSub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click'Now what is the calculation(s) you wish to perform?
EndSub
End
Class
Regards,
John