Link to home
Create AccountLog in
Avatar of Angie532
Angie532

asked on

How do you get the data in VB6

What's the code that will give you today's date in Visual Basic 6?
Can you get the date separate from the time?
Thank you!
Angie
ASKER CERTIFIED SOLUTION
Avatar of Erick37
Erick37
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
You could also get date and time separately using Date() and Time() functions:

Dim dt As Date
Dim tm As Date

'get the date/time now
dt = Date
tm = Time

'display
MsgBox _
"Today is " & Format(dt, "mm/dd/yyyy") & vbCrLf & _
"Time is  " & Format(tm, "hh:nn:ss AMPM")
You can try and do it like so :

Dim strDate As String
strDate = Day(Now) & "/" & Month(Now) & "/" & Year(Now)
MsgBox strDate
MsgBox Format$(Now, "Medium Time")
This site shows you what you can use within the format function, if you use short date within the format function , it will make it display the time in a 24 hour format :)

http://juicystudio.com/tutorial/vb/vbdates.asp