By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,057 Members | 1,401 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,057 IT Pros & Developers. It's quick & easy.

Setting System Time and Date from VB6.0

vdraceil
100+
P: 236
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.
Dec 16 '07 #1
Share this Question
Share on Google+
12 Replies


daniel aristidou
100+
P: 491
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
Dec 25 '07 #2

QVeen72
Expert 100+
P: 1,445
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
Dec 25 '07 #3

P: 41
If memory serves, Windows XP (SP2) and Vista systems update their date and time from the internet every few days.
Dec 26 '07 #4

Expert 5K+
P: 8,434
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?
Dec 29 '07 #5

vdraceil
100+
P: 236
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..
Dec 31 '07 #6

Expert 5K+
P: 8,434
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.
Jan 1 '08 #7

vdraceil
100+
P: 236
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 ?!
Jan 3 '08 #8

lotus18
100+
P: 866
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:

Expand|Select|Wrap|Line Numbers
  1.          Shell "rundll32.exe shell32.dll,Control_RunDLL  timedate.cpl,,0"
  2.  
Rey Sean
Jan 3 '08 #9

vdraceil
100+
P: 236
Hi

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

Expand|Select|Wrap|Line Numbers
  1.          Shell "rundll32.exe shell32.dll,Control_RunDLL  timedate.cpl,,0"
  2.  
Rey Sean
Where do i give the input time and date?
Jan 3 '08 #10

lotus18
100+
P: 866
Where do i give the input time and date?
Have you tried the code?

Rey Sean
Jan 3 '08 #11

Expert 5K+
P: 8,434
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.
Jan 4 '08 #12

QVeen72
Expert 100+
P: 1,445
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
Jan 4 '08 #13

Post your reply

Sign in to post your reply or Sign up for a free account.