?
Solved

How do you get the data in VB6

Posted on 2005-03-06
4
Medium Priority
?
172 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:Angie532
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 32

Accepted Solution

by:
Erick37 earned 200 total points
ID: 13471477
The Date type stores date and time.  Use Now() to get current date/time, and Format() to display it.

Dim dt As Date

'get the date/time now
dt = Now

'display
MsgBox _
"Today is " & Format(dt, "mm/dd/yyyy") & vbCrLf & _
"Time is  " & Format(dt, "hh:nn:ss AMPM")
0
 
LVL 32

Expert Comment

by:Erick37
ID: 13471499
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")
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13474520
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")
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13474526
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
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question