Results 1 to 11 of 11

Thread: [RESOLVED] Code for date reverse..please Enter!

  1. #1

    Thread Starter
    Addicted Member noam309's Avatar
    Join Date
    Aug 2006
    Posts
    225

    Resolved [RESOLVED] Code for date reverse..please Enter!

    Hi,

    I want with button1 click to change the pocket pc current date to (for example- 01.01.1990 , and with button2 click to change the pocket pc to its real date ( for example 14.09.2006)

    Can anyone knows how to do it??


    Giving an exact answer
    Saves a lot of time!!!

  2. #2
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: Code for date reverse..please Enter!

    are you trying to change the date on the pocket pc, or a date variable in your appliciation
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  3. #3

    Thread Starter
    Addicted Member noam309's Avatar
    Join Date
    Aug 2006
    Posts
    225

    Question Re: Code for date reverse..please Enter!

    Yes I'm trying to change the date in my pocket pc for a specific time (that I'll set) and with another button I'll set it back to its real date .

    it is a small app I want to make for using another applications in the pocket pc. means that this small app. will continue to run in my pocket pc while I operate another app.


    Giving an exact answer
    Saves a lot of time!!!

  4. #4
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: Code for date reverse..please Enter!

    This class will allow you to change the time on the device

    VB Code:
    1. Imports System.Runtime.InteropServices
    2.  
    3. Public Class DeviceDateTime
    4.  
    5.     Public Sub New()
    6.  
    7.     End Sub
    8.  
    9.     'System time structure used to pass to P/Invoke...
    10.     <StructLayoutAttribute(LayoutKind.Sequential)> _
    11.     Private Structure SYSTEMTIME
    12.         Public year As Short
    13.         Public month As Short
    14.         Public dayOfWeek As Short
    15.         Public day As Short
    16.         Public hour As Short
    17.         Public minute As Short
    18.         Public second As Short
    19.         Public milliseconds As Short
    20.     End Structure
    21.  
    22.     'P/Invoke dec for setting the system time...
    23.     <DllImport("coredll.dll")> _
    24.     Private Shared Function SetLocalTime(ByRef time As SYSTEMTIME) As Boolean
    25.  
    26.     End Function
    27.  
    28.     Public Function SetDeviceTime(ByVal p_NewDate As Date)
    29.         'Populate structure...
    30.         'Substitute <YOUR DATE OBJECT> with your date object returned via GPRS...
    31.  
    32.         Dim st As SYSTEMTIME
    33.         st.year = p_NewDate.Year
    34.         st.month = p_NewDate.Month
    35.         st.dayOfWeek = p_NewDate.DayOfWeek
    36.         st.day = p_NewDate.Day
    37.         st.hour = p_NewDate.Hour
    38.         st.minute = p_NewDate.Minute
    39.         st.second = p_NewDate.Second
    40.         st.milliseconds = p_NewDate.Millisecond
    41.  
    42.         'Set the new time...
    43.         SetLocalTime(st)
    44.     End Function
    45. End Class
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  5. #5

    Thread Starter
    Addicted Member noam309's Avatar
    Join Date
    Aug 2006
    Posts
    225

    Question Re: Code for date reverse..please Enter!

    Thanks , But I didn't understand how to use it ?

    I need to have 2 buttons in my app:

    1. to change the date of my pocket pc to 01.01.1990

    2. to restore the real date of today.

    Can you tell me how to make this short thing.?

    Giving an exact answer
    Saves a lot of time!!!

  6. #6
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: Code for date reverse..please Enter!

    its a class...
    you create an instance,
    call the function,
    pass in a date you want the device to be changed to

    easy
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  7. #7

    Thread Starter
    Addicted Member noam309's Avatar
    Join Date
    Aug 2006
    Posts
    225

    Question Re: Code for date reverse..please Enter!

    FORGIVE ME , But I don't know how to do it.

    I know that this is a class , but I don't know how to call this function

    can I just put " SetDeviceTime() " in button click ?

    I don't want to change the date every time.

    I just want to make button1 to reverse the date of the pocket pc to 01.01.1990 ( and it suppose to be permanent for button1 , I mean I won't change it only at the code)

    and button2 will return the state into the regular one ( current date).

    what should I put in that 2 buttons?

    Giving an exact answer
    Saves a lot of time!!!

  8. #8
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: Code for date reverse..please Enter!

    You do realise you will have to store the current date in a variable in the application?

    'member variable
    m_originalDate As Date


    button 1
    originalDate = Date.Now()
    Dim l_changeTime As New DeviceDateTime
    l_changeTime.SetDeviceTime(Date.Parse("01/01/1990"))

    button 2
    Dim l_changeTime As New DeviceDateTime
    l_changeTime.SetDeviceTime(m_originalDate)
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  9. #9

    Thread Starter
    Addicted Member noam309's Avatar
    Join Date
    Aug 2006
    Posts
    225

    Smile Re: Code for date reverse..please Enter!

    Thanks,

    I see that this code should be at buttons 1,2

    but I didn't understand this : originalDate = Date.Now()

    isn't it suppose to be : m_originalDate= Date.Now() ?

    thanks for now , I'll check this code at 20:30 PM and let you know how it was.

    Giving an exact answer
    Saves a lot of time!!!

  10. #10
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: Code for date reverse..please Enter!

    oh i cant wait.....
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  11. #11

    Thread Starter
    Addicted Member noam309's Avatar
    Join Date
    Aug 2006
    Posts
    225

    Resolved Re: Code for date reverse..please Enter!

    It is GREAT !!! works perfect thanks.

    Giving an exact answer
    Saves a lot of time!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width