|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
[DATE - newbie] change and set backTOTAL 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? 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. 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.
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/> 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 >/// "an" <a*@inwind.it> schrieb: I have turned them on too (VB.NET 2003) and the code compiles just fine.> 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 -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> 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. "an" <a*@inwind.it> schrieb: Re-check my solution. The screenshots are not showing the solution I >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 posted! -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> > Sorry>Re-check my solution. The screenshots are not showing the solution I >posted! 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? "an" <a*@inwind.it> schrieb: Did you already check out the documentation on both? To do so, place the > what's the difference beteween > aaa = Today > aaa = DateTime.Today > both works, > so what the difference consist of? caret over them and press the F1 key. > If I want to perform the same task, Maybe you want to use 'TimeOfDay' instead of 'Today'.> but changing the time only > (set to: h 10 m 10 s10 ) > and then set it back? -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> 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: I did:>> 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. 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, shortly back to the time setting 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'. 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? "an" <a*@inwind.it> schrieb: 'Date' and 'DateTime' are types. 'Date' is VB's alias for 'DateTime'. > Also, we have: > Date, DateTime, DateandTime, Today, DateTime.Today, DateAndTime.Today > isn't it? '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, 'DateTime' is actually a type, but VB defines 'Date' as an alias for > but at the beginning I declared : > Dim aaa As DateTime > while DateTime is not a Type (although the IDE gave me no error). '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/>
Web Browser in Windows App
Unused variables that really are?!? RS232 - Recive = Send???? Debug.Wrile does not appear on the Output Window GetCurrentProcess.Id vs GetCurrentProcessId API Can't delete an image that is in a picture box Trying to execute something stored in variable Form Visibility Issue VB.NET 2003 Paste logo on image A Question of form focus - VB.NET 2003 |
|||||||||||||||||||||||