Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Date and time in VB
Name: raylu Date: January 1, 2004 at 11:15:46 Pacific OS: XP Pro CPU/Ram: 1.1G
Comment:
I feel really stupid for asking this but how do you get the current date and time in VB?
Name: StuartS Date: January 1, 2004 at 13:57:49 Pacific
Reply:
Use the system variable Date and Time.
Stuart
0
Response Number 2
Name: raylu Date: January 1, 2004 at 14:51:34 Pacific
Reply:
Oh... ;-) Thanks.
0
Response Number 3
Name: Burbble Date: January 2, 2004 at 21:37:23 Pacific
Reply:
You can also use Date$ (which returns the date using different separators - colons instead of backslashes, I think) and Time$ (which returns military time).
-Burbble
0
Response Number 4
Name: StuartS Date: January 2, 2004 at 23:07:31 Pacific
Reply:
Well actually Date and Date$ and Time and Time$ return exactly the same thing. The format is determined by the setting in Control Panel > Regional Settings.
If you format the time with HH you get a 24 hour clock. hh gives you a twelve hour clock. tt on the end of the format string gives you AM or PM as appropriate.
Now or Now$ in VB will give you the date and time combined.
Stuart
0
Response Number 5
Name: raylu Date: January 3, 2004 at 10:12:28 Pacific
Reply:
Thank you all for replying. I need it to find how long a program takes to execute, so I took the Left 2 characters of the Right 5 characters of the Time for the start and end time and subtracted it (Using a time won't work, I already tried). There has to be an easier way. By the way, thanks for the Now. I've been using Date & " " & Time.
0
Response Number 6
Name: StuartS Date: January 3, 2004 at 13:40:00 Pacific
Reply:
Thats not a very good way of timing events within a programme. Although the system clock can be very accurate, its resolution os not so good. At best 1/18th of a second.
A better method is to use the GetTickCount API. Thus returns the number of milliseconds since the computer was started.
Call the function at the start of the event and save the result. Call it again at then end of the event. Subtract one from the other and a bit of devision and you have an answer accurate to 15Ms
Public Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
Stuart
0
Response Number 7
Name: wsd Date: January 9, 2004 at 00:07:00 Pacific
Reply:
EXAMPLE: Dim Mydate As String Mydate = Format(Date, "dddd, mmm d yyyy, hh:mm:ss AMPM")
Summary: hi how can i create a text file using batch file with date and time in name eg testThu 02/08/2007 2300.txt and also i want to read a text file which has list of IP address and execute same command o...
Summary: I need to write a batch file that will look at the files in a specific folder, and copy the latest file (to the minute of possible) to a different directory. Does anyone know what to write in a Batch...
Summary: I've large network with over 200 servers. There is one bat file (d:\abc\xy\*.bat) exists on all servers in network. I need to get the date and time of this bat file. Please help me to create bat file ...