Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 11th, 2010, 03:31 AM
Registered User
 
Join Date: Sep 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default Miner Date / Time problem

Hi all;

I’ve got my code so far, it works but the wrong way around I want to check if the date / time in label1 (which I get from the DB) is smaller than two minutes comparing with the system date time. But what happens now is when the system date / time is < 2 minutes I get a massage and if it is over 2 minutes then I don’t get the message any more, I don’t know what I am missing help will be much appreciated.

Code:
Private Sub Command1_Click()
    Dim date1 As Date
    date1 = Format(label1, "yyyy/mm/dd hh:mm:ss")
    If DateDiff("n", date1, Now) < 2 Then
       MsgBox ("Not Vending")
    End If
End Sub
 
Old January 11th, 2010, 04:56 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Code:
Private Sub Command1_Click()
    Dim date1 As Date
    date1 = Format(Label1, "yyyy/mm/dd hh:mm:ss")
    
    Dim s As Integer
    s = DateDiff("n", date1, Now)
    If s > 2 Then
       MsgBox (s & ": Not Vending")
    End If
End Sub
__________________
Om Prakash Pant
Click the "Thanks" button if this post helped you.
The Following User Says Thank You to om_prakash For This Useful Post:
[email protected] (January 11th, 2010)





Similar Threads
Thread Thread Starter Forum Replies Last Post
date-time problem naveed77 Beginning VB 6 0 February 3rd, 2007 11:43 AM
date-time problem naveed77 Beginning VB 6 0 February 1st, 2007 07:13 AM
Date and Time Problem. rupen Classic ASP Professional 1 June 6th, 2006 06:00 AM
print time and date problem zouky Crystal Reports 0 November 11th, 2004 10:32 PM
Date And Time Problem tsukey PHP Databases 0 July 28th, 2004 10:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.