[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??
:confused: :confused: :confused:
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
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.
:confused:
Re: Code for date reverse..please Enter!
This class will allow you to change the time on the device
VB Code:
Imports System.Runtime.InteropServices
Public Class DeviceDateTime
Public Sub New()
End Sub
'System time structure used to pass to P/Invoke...
<StructLayoutAttribute(LayoutKind.Sequential)> _
Private Structure SYSTEMTIME
Public year As Short
Public month As Short
Public dayOfWeek As Short
Public day As Short
Public hour As Short
Public minute As Short
Public second As Short
Public milliseconds As Short
End Structure
'P/Invoke dec for setting the system time...
<DllImport("coredll.dll")> _
Private Shared Function SetLocalTime(ByRef time As SYSTEMTIME) As Boolean
End Function
Public Function SetDeviceTime(ByVal p_NewDate As Date)
'Populate structure...
'Substitute <YOUR DATE OBJECT> with your date object returned via GPRS...
Dim st As SYSTEMTIME
st.year = p_NewDate.Year
st.month = p_NewDate.Month
st.dayOfWeek = p_NewDate.DayOfWeek
st.day = p_NewDate.Day
st.hour = p_NewDate.Hour
st.minute = p_NewDate.Minute
st.second = p_NewDate.Second
st.milliseconds = p_NewDate.Millisecond
'Set the new time...
SetLocalTime(st)
End Function
End Class
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.? :confused:
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
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?
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)
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.
Re: Code for date reverse..please Enter!
oh i cant wait..... :bigyello:
Re: Code for date reverse..please Enter!
It is GREAT !!! works perfect thanks.