Home All Groups Group Topic Archive Search About

[DATE - newbie] change and set back

Author
22 Apr 2006 5:57 PM
an
TOTAL NEWBIE

I need to change the date to 05/05/2005,
display a messagebox,
then set the current date back.

In VB6 I use:

aaa = Date
Date = #05/05/2005#
Msgbox "Hallo"
Date = aaa


In VbNet I'm in a nightmare.
Can you help me?

Author
22 Apr 2006 6:13 PM
Steve_Black
Are you saying you need to change the computer's system date?

If so, I'm not sure how to do that.  However, to get access to the date
use Today.Date.
Author
22 Apr 2006 7:38 PM
an
Yes I need to change the computer's system date,
after having stored the current one in a variable,
then set it back...


Show quoteHide quote
>Are you saying you need to change the computer's system date?
>
>If so, I'm not sure how to do that.  However, to get access to the date
>use Today.Date.
Author
22 Apr 2006 10:13 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"an" <a*@inwind.it> schrieb:
> I need to change the date to 05/05/2005,
> display a messagebox,
> then set the current date back.
>
> In VB6 I use:
>
> aaa = Date
> Date = #05/05/2005#
> Msgbox "Hallo"
> Date = aaa
>
>
> In VbNet I'm in a nightmare.

\\\
Dim aaa As Date = Today
Today = #5/5/2005#
MsgBox("Hallo")
Today = aaa
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
23 Apr 2006 2:27 AM
an
The snippet doesn't work
all the rows
(except the MessageBox one)
have one or more errors.

Note:
I use Option Explicit and option Strict both set ON






Show quoteHide quote
>"an" <a*@inwind.it> schrieb:
>> I need to change the date to 05/05/2005,
>> display a messagebox,
>> then set the current date back.
>>
>> In VB6 I use:
>>
>> aaa = Date
>> Date = #05/05/2005#
>> Msgbox "Hallo"
>> Date = aaa
>>
>>
>> In VbNet I'm in a nightmare.
>
>\\\
>Dim aaa As Date = Today
>Today = #5/5/2005#
>MsgBox("Hallo")
>Today = aaa
>///
Author
23 Apr 2006 11:28 AM
Herfried K. Wagner [MVP]
"an" <a*@inwind.it> schrieb:
> The snippet doesn't work
> all the rows
> (except the MessageBox one)
> have one or more errors.
>
> Note:
> I use Option Explicit and option Strict both set ON

I have turned them on too (VB.NET 2003) and the code compiles just fine.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
23 Apr 2006 1:03 PM
an
I have VS2005 TeamSuite Italian.

First of all
I've turned now both the Option Explicit and Strict OFF
to have more flexiblity.

------

I did two attempts
se gif image (20 Kb) with errors at:
http://img91.imageshack.us/img91/2753/twosnips2kd.gif


Show quoteHide quote
>"an" <a*@inwind.it> schrieb:
>> The snippet doesn't work
>> all the rows
>> (except the MessageBox one)
>> have one or more errors.
>>
>> Note:
>> I use Option Explicit and option Strict both set ON
>
>I have turned them on too (VB.NET 2003) and the code compiles just fine.
Author
23 Apr 2006 1:34 PM
Herfried K. Wagner [MVP]
"an" <a*@inwind.it> schrieb:
>I have VS2005 TeamSuite Italian.
>
> First of all
> I've turned now both the Option Explicit and Strict OFF
> to have more flexiblity.
>
> ------
>
> I did two attempts
> se gif image (20 Kb) with errors at:
> http://img91.imageshack.us/img91/2753/twosnips2kd.gif

Re-check my solution.  The screenshots are not showing the solution I
posted!

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
23 Apr 2006 3:49 PM
an
>
>Re-check my solution.  The screenshots are not showing the solution I
>posted!

Sorry
it was driving me crazy;
it works,


I have a couple of questions:

what's the difference beteween
aaa = Today
aaa = DateTime.Today
both works,
so what the difference consist of?

If I want to perform the same task,
but changing the time only
(set to:   h 10    m 10    s10 )
and then set it back?
Author
23 Apr 2006 8:44 PM
Herfried K. Wagner [MVP]
"an" <a*@inwind.it> schrieb:
> what's the difference beteween
> aaa = Today
> aaa = DateTime.Today
> both works,
> so what the difference consist of?

Did you already check out the documentation on both?  To do so, place the
caret over them and press the F1 key.

> If I want to perform the same task,
> but changing the time only
> (set to:   h 10    m 10    s10 )
> and then set it back?

Maybe you want to use 'TimeOfDay' instead of 'Today'.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
23 Apr 2006 10:35 PM
an
On Sun, 23 Apr 2006 22:44:26 +0200, "Herfried K. Wagner [MVP]"
<hirf-spam-me-here@gmx.at> wrote:

>"an" <a*@inwind.it> schrieb:
>> what's the difference beteween
>> aaa = Today
>> aaa = DateTime.Today
>> both works,
>> so what the difference consist of?
>
>Did you already check out the documentation on both?  To do so, place the
>caret over them and press the F1 key.


I did:
Today seems a member of the DateandTime module
but
honestly I didn't understand a lot about the usage difference
also because in the same datetime.today  page

there is the following example

Dim value As DateTime
value = DateAndTime.Today
DateAndTime.Today = value

and then this slightly different one

Dim thisDate As Date
thisDate = Today

so currently I 'm not sure about the usage
of datetime.today  and  of today

----------

Also, we have:
Date,  DateTime,  DateandTime,  Today,  DateTime.Today,  DateAndTime.Today
isn't it?
Well I'm confused;
just to not bother you,
have you a page with a schema/diagram/chart ?



>> If I want to perform the same task,
>> but changing the time only
>> (set to:   h 10    m 10    s10 )
>> and then set it back?
>
>Maybe you want to use 'TimeOfDay' instead of 'Today'.


shortly back to the time setting task:

by following your hint, I succeeded,
but at the beginning I declared :
Dim aaa As DateTime
while DateTime is not a Type (although the IDE gave me no error).

How would you have declared it?
Author
23 Apr 2006 10:53 PM
Herfried K. Wagner [MVP]
"an" <a*@inwind.it> schrieb:
> Also, we have:
> Date,  DateTime,  DateandTime,  Today,  DateTime.Today,  DateAndTime.Today
> isn't it?

'Date' and 'DateTime' are types.  'Date' is VB's alias for 'DateTime'.
'DateTime' has a 'Today' property, thus you can either write
'DateTime.Today' or 'Date.Today'.

'DateAndTime' is a module in VB's function library
("Microsoft.VisualBasic.dll").  'Today' is a property of this module.  As
modules are imported automatically in VB, it's not necessary to qualify
access to the 'Today' property with the name of the module containing it
('DateAndTime.Today').

> by following your hint, I succeeded,
> but at the beginning I declared :
> Dim aaa As DateTime
> while DateTime is not a Type (although the IDE gave me no error).

'DateTime' is actually a type, but VB defines 'Date' as an alias for
'DateTime'.  Thus personally I always use 'Date' instead of 'DateTime' in my
code.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>