Solved

To emoreau

Posted on 2000-03-07
4
229 Views
Last Modified: 2010-05-02
emoreau,
Is it possible to break up the Minute,Hour,Day,Month & Year into
seperate textboxes.From your previous answer to my Date subtract question.
Thanks
Dave Steers
0
Comment
Question by:dsteers
  • 2
4 Comments
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2590948
Sure thing, you can use the.. hold on to ya hat now... the Year(Date), Month(Date), Day(Date), Hour(Date), Minute(Date) functions. For example...

  Me.Caption = Year(Now)       'shows the year number
  Me.Caption = Month(Now)    'shows the month number
  Me.Caption = Day(Now)        'shows the day number
  Me.Caption = Hour(Now)      'shows the hour number
  Me.Caption = Minute(Now)   'shows the minute number
  Me.Caption = Second(Now)  'guess what?
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 20 total points
ID: 2591607
Thanks for the points!
0
 

Author Comment

by:dsteers
ID: 2603578
Guys,
Using the following code how do I seperate the Day,Month & Year into
seperate textboxes so that they can be entered by the user.
I.e 2 Day textboxes,2 Month textboxes & 2 Year textboxes.
Thanks

Code (thanks to emoreau)

Option Explicit

Private Sub Command1_Click()
Dim dtm1 As Date
Dim dtm2 As Date
Dim lngDiff As Long
Dim lngDays As Long
Dim lngHours As Long
Dim lngMinutes As Long

    dtm1 = "2000/03/08 13:40"
    dtm2 = "2000/03/09 2:00"
     
    'Returns number of minutes
    lngDiff = DateDiff("n", dtm1, dtm2)
     
    'Extract days
    If lngDiff > (24 * 60) Then
        lngDays = Int(lngDiff / (24 * 60))
        lngDiff = lngDiff - (lngDays * 24 * 60)
    End If
     
    'Extract Hours
    If lngDiff > 60 Then
        lngHours = Int(lngDiff / 60)
        lngDiff = lngDiff - (lngHours * 60)
    End If
     
    'Extract Minutes
    lngMinutes = lngDiff
     
    MsgBox "Difference between dates: " & _
           lngDays & " days, " & _
           lngHours & " hours and " & _
           lngMinutes & " minutes."
End Sub

Thanks
Dave Steers
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2604469
You can use the CDate to build your date:

    dtm1 = CDate(txtYear1 & "/" & txtMonth1 & "/" & txtDay1 & " " & txtHour1 & ":" & txtMinute1)
    dtm2 = CDate(txtYear2 & "/" & txtMonth2 & "/" & txtDay2 & " " & txtHour2 & ":" & txtMinute2)
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
add text to end of existing text in file 16 71
VB 6.0 printer how to align 6 62
Put text in a picture ASP.NET C# 2 58
How to read File Date Created using VB6 8 40
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

831 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