Setting System Time and Date from VB6.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vdraceil
    New Member
    • Jul 2007
    • 236

    Setting System Time and Date from VB6.0

    Hi experts, I have a question. Is it possible to set (change/edit) the system time and date by coding in vb6.0? I think it's not possible (80%) but maybe experts might have an answer - I suppose.
    Last edited by Killer42; Dec 17 '07, 02:42 AM.
  • daniel aristidou
    Contributor
    • Aug 2007
    • 494

    #2
    Originally posted by vdraceil
    Hi experts, I have a question. Is it possible to set (change/edit) the system time and date by coding in vb6.0? I think it's not possible (80%) but maybe experts might have an answer - I suppose.
    I could not find a way from vb 6 however there is a way using vb 2005.
    Visual Basic 2005
    Visual Basic 2005 replaces Date and Time with the Today and TimeOfDay properties, which use the eight-byte common language runtime (CLR) DateTime structure. This corresponds with the Date data type in Visual Basic 2005. You can use Today and TimeOfDay to both set and fetch the system date and time.

    Visual Basic 2005 replaces the Date$ and Time$ functions with the DateString and TimeString properties. You can use DateString and TimeString to both set and fetch the system date and time.

    The Now and Timer functions are replaced by read-only properties of the same names. Their calling sequences remain unchanged.

    Merry Christmas

    Comment

    • QVeen72
      Recognized Expert Top Contributor
      • Oct 2006
      • 1445

      #3
      Originally posted by vdraceil
      Hi experts, I have a question. Is it possible to set (change/edit) the system time and date by coding in vb6.0? I think it's not possible (80%) but maybe experts might have an answer - I suppose.

      Hi,

      Date = CDate("29-12-2007")

      Regards
      Veena

      Comment

      • Torgg
        New Member
        • Dec 2007
        • 41

        #4
        If memory serves, Windows XP (SP2) and Vista systems update their date and time from the internet every few days.

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by Torgg
          If memory serves, Windows XP (SP2) and Vista systems update their date and time from the internet every few days.
          Only if you configure them that way.

          In fact, I don't think XP has that built in at all, does it? Don't you have to download synchronisation software from somewhere? Or am I think of an earlier version of Windows?

          Comment

          • vdraceil
            New Member
            • Jul 2007
            • 236

            #6
            Originally posted by QVeen72
            Hi,

            Date = CDate("29-12-2007")

            Regards
            Veena
            Thanks for replying..
            Isn't CDate() a conversion type function like CInt,CSng etc..Will it set system time?! Please clear my doubt..

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              Originally posted by vdraceil
              Thanks for replying..
              Isn't CDate() a conversion type function like CInt,CSng etc..Will it set system time?! Please clear my doubt..
              That's right. The CDate function in that code was simply converting the string to a date value.

              I have no idea whether it works or not, but assigning the value to Date must be what was intended to do the job.

              Comment

              • vdraceil
                New Member
                • Jul 2007
                • 236

                #8
                Originally posted by Killer42
                That's right. The CDate function in that code was simply converting the string to a date value.

                I have no idea whether it works or not, but assigning the value to Date must be what was intended to do the job.
                So we dont have a possibility of setting time by code in vb6.0 ?!

                Comment

                • lotus18
                  Contributor
                  • Nov 2007
                  • 865

                  #9
                  Originally posted by vdraceil
                  So we dont have a possibility of setting time by code in vb6.0 ?!
                  Hi

                  If you want to modify the current system date and time you can try this:

                  [CODE=vb] Shell "rundll32.e xe shell32.dll,Con trol_RunDLL timedate.cpl,,0 "
                  [/CODE]

                  Rey Sean

                  Comment

                  • vdraceil
                    New Member
                    • Jul 2007
                    • 236

                    #10
                    Originally posted by lotus18
                    Hi

                    If you want to modify the current system date and time you can try this:

                    [CODE=vb] Shell "rundll32.e xe shell32.dll,Con trol_RunDLL timedate.cpl,,0 "
                    [/CODE]

                    Rey Sean
                    Where do i give the input time and date?

                    Comment

                    • lotus18
                      Contributor
                      • Nov 2007
                      • 865

                      #11
                      Originally posted by vdraceil
                      Where do i give the input time and date?
                      Have you tried the code?

                      Rey Sean

                      Comment

                      • Killer42
                        Recognized Expert Expert
                        • Oct 2006
                        • 8429

                        #12
                        From VB6 Help...
                        Date Statement

                        Sets the current system date.

                        Syntax

                        Date = date

                        For systems running Microsoft Windows 95, the required date specification must be a date from January 1, 1980 through December 31, 2099. For systems running Microsoft Windows NT, date must be a date from January 1, 1980 through December 31, 2079.

                        Comment

                        • QVeen72
                          Recognized Expert Top Contributor
                          • Oct 2006
                          • 1445

                          #13
                          Originally posted by vdraceil
                          Isn't CDate() a conversion type function like CInt,CSng etc..Will it set system time?! Please clear my doubt..
                          hi,

                          It will change the system date.. why dont you try it..?

                          Regards
                          Veena

                          Comment

                          Working...