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 June 8th, 2007, 04:30 AM
Authorized User
 
Join Date: May 2007
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to MathLearner
Default date and time1

hi :)
      how to adjust system date and time using vb..

      For this i have developed a function..
Actually i need to reduce the minute by 1 when i use this function.. When i reduce the minute it was reducing correctly.. but when minute is in 0 means at that time i need to reduce the hour also..
         for example current time is 03:22:23
              it was reduced correctly as 03:21:23
                     but
                         when the time is in 03:00:02 means it need to be reduced as 02:59:02..
      It was reading correctly but when it sets the time problem arises for this situation..
         coding is given below..


Dim mm1 As Integer
Dim dd As String
Dim hh As Integer
Dim ss As Integer
Dim yy As String
Dim mo As String
Dim ww As String
Dim hour1 As Integer

Private Type SystemTime
    wYear As Integer
    wMonth As Integer
    wDayOfWeek As Integer
    wDay As Integer
    wHour As Integer
    wMinute As Integer
    wSecond As Integer
    wMilliseconds As Integer
    lpSystemTime As Long

End Type
Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SystemTime) As Long
Private Sub Form_Load()

    time1 = Now
    If (minute(Time) > 0) Then
    mm1 = minute(Time) - 1
    ElseIf (hour(Time) > 0) Then
    hour1 = hour(Time) - 1
    mm1 = 59
    End If
    dd = Day(Date)
    ss = Second(Time)
    yy = Year(Date)
    mo = Month(Date)
    ww = Weekday(Date, vbUseSystemDayOfWeek)

    Dim lpSystemTime As SystemTime
    lpSystemTime.wYear = yy
    lpSystemTime.wMonth = mo
    lpSystemTime.wDayOfWeek = ww
    lpSystemTime.wDay = dd
    lpSystemTime.wHour = hour1
    lpSystemTime.wMinute = mm1
    lpSystemTime.wSecond = ss
    lpSystemTime.wMilliseconds = 0
    'set the new time
    SetSystemTime lpSystemTime

End Sub


 PLEASE help me

 
Old June 8th, 2007, 07:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there.. you didn't read about the dateadd function??

it will solve all your code in a second....

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old June 8th, 2007, 11:18 PM
Authorized User
 
Join Date: May 2007
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to MathLearner
Default

hi
  Gonzalo has replied.. but i cant able to see the reply.. any pblm in the forum..
          help me..:(

 
Old June 11th, 2007, 07:06 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there.. my reply again:

you didn't read about the dateadd function??

it will solve all your code in a second....

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Show Images from Start Date thru Date istcomnet Classic ASP Basics 2 May 23rd, 2008 07:12 AM
How to find a date range between another date rang tayvonne Access 2 August 3rd, 2006 09:50 AM
How to give Date format while entering date Subuana Beginning VB 6 4 March 17th, 2006 07:25 AM
DTS Import ( Date string to Date field) gfowajuh SQL Server 2000 1 September 30th, 2003 06:28 AM
Convert String Date to Date for a SQL Query tdaustin Classic ASP Basics 4 July 7th, 2003 06:01 PM





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