Click to See Complete Forum and Search --> : visual basic in excel


SteveW
August 22nd, 2001, 02:14 PM
Here is an odd occurance. I am creating a time sheet in excel and using some of the visual basic commands in the background.

Here is the breakdown:
Enter the date and press return.
Next 2 weeks worth of dates appear on the excel form.
As soon as i press enter for the date, the sytem date is changed to match the date that i just entered. (System date is the date on my taskbar).

Any tips on avoiding this problem?
Thank You in advance.

Here is my code:


Private Sub cmdEnter_Click()

Date = txtDate.Value

lblSunDate1.Caption = Date
lblMonDate1.Caption = Date + 1
lblTueDate1.Caption = Date + 2
lblWedDate1.Caption = Date + 3
lblThuDate1.Caption = Date + 4
lblFriDate1.Caption = Date + 5
lblSatDate1.Caption = Date + 6

lblSunDate2.Caption = Date + 7
lblMonDate2.Caption = Date + 8
lblTueDate2.Caption = Date + 9
lblWedDate2.Caption = Date + 10
lblThuDate2.Caption = Date + 11
lblFriDate2.Caption = Date + 12
lblSatDate2.Caption = Date + 13

End Sub

Ghost308
August 22nd, 2001, 02:38 PM
Switch the line

Date = txtDate.Value

to this...

txtDate.Value = Date

Iouri
August 22nd, 2001, 03:09 PM
Also change
lblMonDate1.Caption = Date + 1
to
lblMonDate1.Caption = DateAdd("d", 1, Date)' add 1 day
lblTueDate1.Caption = DateAdd("d", 2, Date)' add 2 days
etc


Iouri Boutchkine
iouri@hotsheet.com

hoa01206
August 22nd, 2001, 04:35 PM
Hi,

Date, is a vb keyword that trigger the system date or get the system date.

use another variable name

instead of
Date = txtDate.Value

use
Date1 = txtDate.Value

Thanks
Hisham