CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2001
    Location
    Cleveland, Ohio
    Posts
    3

    visual basic in excel

    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


  2. #2
    Join Date
    Jun 2001
    Location
    Memphis, TN
    Posts
    146

    Re: visual basic in excel

    Switch the line

    Date = txtDate.Value

    to this...

    txtDate.Value = Date


  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: visual basic in excel

    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
    [email protected]
    Iouri Boutchkine
    [email protected]

  4. #4
    Join Date
    Aug 2001
    Location
    PA
    Posts
    150

    Re: visual basic in excel

    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
    Thank You, Hisham

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured