|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
simple format questionIn order to create a date in CCYY-MM-DD fashion, I used to be able to use
the Format(date,"yyyy")&"-"&Format(month,"mm")... syntax... This no longer appears to work in vb.net. I know how I could do this..., by prepending a "0" to the month and taking the right 2 characters, but that is silly. What is the new "easy" way ? Is there a list some where of all the string and date manipulation functions with "old" and "new" methods somewhere ? Thanks ! "Rob" <ro***@yahoo.com> wrote in you need cap M's...news:XsSdnYMGiPtd2PrYnZ2dnUVZ_vqdnZ2d@comcast.com: > In order to create a date in CCYY-MM-DD fashion, I used to be able to > use the Format(date,"yyyy")&"-"&Format(month,"mm")... syntax... > > This no longer appears to work in vb.net. > > > format (Now, "yyyy-MM-dd") MessageBox.Show(Format(DateTime.Now, "yy-MM-dd"))
Newbie Coder Show quoteHide quote "tony obrien" <tob_@_sourcecode-inc.com> wrote in message news:Xns988595A6D514Dtobsourcecodeinccom@130.81.64.196... > "Rob" <ro***@yahoo.com> wrote in > news:XsSdnYMGiPtd2PrYnZ2dnUVZ_vqdnZ2d@comcast.com: > > > In order to create a date in CCYY-MM-DD fashion, I used to be able to > > use the Format(date,"yyyy")&"-"&Format(month,"mm")... syntax... > > > > This no longer appears to work in vb.net. > > > > > > > > you need cap M's... > > format (Now, "yyyy-MM-dd") There's a list of all the string and date manipulation
functions and how to use them in Francesco Balena's book, VB2005:The Language. This is an excellent book for lots of reasons. Great reference. Another interesting book is "The .Net Languages: A Quick Translation Guide" by Brian Bischof. This has VB6, VB.Net, and C#.Net syntax for a bunch of common code, like data types and operators, exception handling, classes (and all that involves), events, string management, windows forms, date and time functions, match and financial calcs, collections, etc. I have found it very helpful. The only gotcha is that it's probably for .Net 2002. But I still find it helpful when just looking for syntax diffs between VB.Net and C#.Net (I can't ever remember how to cast in C#, or implement interfaces. Sigh.) Robin S. ------------------------------------ Show quoteHide quote "Rob" <ro***@yahoo.com> wrote in message news:XsSdnYMGiPtd2PrYnZ2dnUVZ_vqdnZ2d@comcast.com... > In order to create a date in CCYY-MM-DD fashion, I used to be able to use > the Format(date,"yyyy")&"-"&Format(month,"mm")... syntax... > > This no longer appears to work in vb.net. I know how I could do this..., > by prepending a "0" to the month and taking the right 2 characters, but > that is silly. > > What is the new "easy" way ? > > Is there a list some where of all the string and date manipulation > functions with "old" and "new" methods somewhere ? > > Thanks ! > RobinS wrote:
> There's a list of all the string and date manipulation <snip>> The only gotcha is that it's probably for .Net 2002. But Really? If anything I think the VB.NET version of both is harder...> I still find it helpful when just looking for syntax diffs > between VB.Net and C#.Net (I can't ever remember how to > cast in C#, or implement interfaces. Sigh.) > In fact, I like the C# as syntax when working with reference types because you can avoid invalid cast exceptions and simply check for null. The VB.NET way of interfaces is way to wordy for my taste - of course it does have the nice side effect of allowing you to rename the interface method... -- Tom Shelton Tom,
I don't like those C# evangelists in this newsgroup. :-) Are you a newbie wanting a war?:-) CorShow quoteHide quote "Tom Shelton" <tom_shel***@comcast.net> schreef in bericht news:1164444606.121832.141230@45g2000cws.googlegroups.com... > > RobinS wrote: >> There's a list of all the string and date manipulation > > <snip> > >> The only gotcha is that it's probably for .Net 2002. But >> I still find it helpful when just looking for syntax diffs >> between VB.Net and C#.Net (I can't ever remember how to >> cast in C#, or implement interfaces. Sigh.) >> > > Really? If anything I think the VB.NET version of both is harder... > In fact, I like the C# as syntax when working with reference types > because you can avoid invalid cast exceptions and simply check for > null. > > The VB.NET way of interfaces is way to wordy for my taste - of course > it does have the nice side effect of allowing you to rename the > interface method... > > -- > Tom Shelton > Cor Ligthert [MVP] wrote:
> Tom, Cor, I'm not evangelizing :) I like VB.NET - I just happen to like the> > I don't like those C# evangelists in this newsgroup. > > :-) > terser syntax of C-style languages. So, int i = (int) someValue; makes more sense to me then using" Dim i As Integer = CType (someValue, Integer) > Are you a newbie wanting a war? No wars needed :)> > :-) -- Tom Shelton I like to program in VB. I find there's too much whitespace
in C# -- all those blank lines with nothing but parentheses or curly brackets. I think VB's "Implements IBindingList" is a lot clearer than "sub name : IBindingList". As a VB programmer, I had no idea what that meant the first time I saw it! Sometimes being more verbose is better for readability and long-term maintainability. And I don't get the thing about checking against Null. Null, Nothing, it's only 3 more characters, so what's the diff? But everyone is different, and it's probably what you're used to that makes the most sense to you. So I celebrate your right to enjoy C# more than VB, while retaining mine to do the opposite! (Put your boots on! It's getting deep in here!) Robin S. ------------------ Show quoteHide quote "Tom Shelton" <tom_shel***@comcast.net> wrote in message news:1164444606.121832.141230@45g2000cws.googlegroups.com... > > RobinS wrote: >> There's a list of all the string and date manipulation > > <snip> > >> The only gotcha is that it's probably for .Net 2002. But >> I still find it helpful when just looking for syntax diffs >> between VB.Net and C#.Net (I can't ever remember how to >> cast in C#, or implement interfaces. Sigh.) >> > > Really? If anything I think the VB.NET version of both is harder... > In fact, I like the C# as syntax when working with reference types > because you can avoid invalid cast exceptions and simply check for > null. > > The VB.NET way of interfaces is way to wordy for my taste - of course > it does have the nice side effect of allowing you to rename the > interface method... > > -- > Tom Shelton > RobinS wrote:
Show quoteHide quote > I like to program in VB. I find there's too much whitespace Robin - I hope you realize that I ment no offense by my comments. I> in C# -- all those blank lines with nothing but parentheses > or curly brackets. I think VB's "Implements IBindingList" > is a lot clearer than "sub name : IBindingList". As a VB > programmer, I had no idea what that meant the first time > I saw it! Sometimes being more verbose is better for > readability and long-term maintainability. > > And I don't get the thing about checking against Null. > Null, Nothing, it's only 3 more characters, so what's > the diff? > > But everyone is different, and it's probably what you're > used to that makes the most sense to you. So I celebrate > your right to enjoy C# more than VB, while retaining mine > to do the opposite! (Put your boots on! It's getting deep > in here!) like VB.NET just fine. I just happen to like C-style languages more. And yes, I even like case sensitivity (and no, I don't have a good reason for it :). You have every right to use the language you enjoy most :) -- Tom Shelton
Show quote
Hide quote
"Tom Shelton" <tom_shel***@comcast.net> wrote in message Oh, no, I didn't think you meant any offense by your comments.news:1164510099.683310.109710@h54g2000cwb.googlegroups.com... > > RobinS wrote: >> I like to program in VB. I find there's too much whitespace >> in C# -- all those blank lines with nothing but parentheses >> or curly brackets. I think VB's "Implements IBindingList" >> is a lot clearer than "sub name : IBindingList". As a VB >> programmer, I had no idea what that meant the first time >> I saw it! Sometimes being more verbose is better for >> readability and long-term maintainability. >> >> And I don't get the thing about checking against Null. >> Null, Nothing, it's only 3 more characters, so what's >> the diff? >> >> But everyone is different, and it's probably what you're >> used to that makes the most sense to you. So I celebrate >> your right to enjoy C# more than VB, while retaining mine >> to do the opposite! (Put your boots on! It's getting deep >> in here!) > > > Robin - I hope you realize that I ment no offense by my comments. I > like VB.NET just fine. I just happen to like C-style languages more. > And yes, I even like case sensitivity (and no, I don't have a good > reason for it :). > > You have every right to use the language you enjoy most :) > -- > Tom Shelton > I thought we were just kind of jibing at each other with humor, but both respecting the other's opinions and wishes. Have fun, Robin S. Oh my!
VB.NET vs C# is a debate that is never going to have an end! Let us distill it to one simple maxim? Which language do you prefer? That one's the best Show quoteHide quote On 25 Nov 2006 00:50:06 -0800, "Tom Shelton" <tom_shel***@comcast.net> --wrote: > >RobinS wrote: >> There's a list of all the string and date manipulation > ><snip> > >> The only gotcha is that it's probably for .Net 2002. But >> I still find it helpful when just looking for syntax diffs >> between VB.Net and C#.Net (I can't ever remember how to >> cast in C#, or implement interfaces. Sigh.) >> > >Really? If anything I think the VB.NET version of both is harder... >In fact, I like the C# as syntax when working with reference types >because you can avoid invalid cast exceptions and simply check for >null. > >The VB.NET way of interfaces is way to wordy for my taste - of course >it does have the nice side effect of allowing you to rename the >interface method... Bits.Bytes. http://bytes.thinkersroom.com I agree!
Robin S. ------------------- Show quoteHide quote "Rad [Visual C# MVP]" <nospam@nospam.com> wrote in message news:0h5hm2to3gvea04m3uidpst849fhc9kb4p@4ax.com... > Oh my! > > VB.NET vs C# is a debate that is never going to have an end! > > Let us distill it to one simple maxim? > > Which language do you prefer? That one's the best > > On 25 Nov 2006 00:50:06 -0800, "Tom Shelton" <tom_shel***@comcast.net> > wrote: > >> >>RobinS wrote: >>> There's a list of all the string and date manipulation >> >><snip> >> >>> The only gotcha is that it's probably for .Net 2002. But >>> I still find it helpful when just looking for syntax diffs >>> between VB.Net and C#.Net (I can't ever remember how to >>> cast in C#, or implement interfaces. Sigh.) >>> >> >>Really? If anything I think the VB.NET version of both is harder... >>In fact, I like the C# as syntax when working with reference types >>because you can avoid invalid cast exceptions and simply check for >>null. >> >>The VB.NET way of interfaces is way to wordy for my taste - of course >>it does have the nice side effect of allowing you to rename the >>interface method... > -- > > Bits.Bytes. > http://bytes.thinkersroom.com Robin,
I was only tickling Tom, he is one of the longest regulars from the VB.Net newsgroup.] For you the casting equivalent in c# is. DirectCast is in C# x as myType Ctype is in C# (myType) x That is so much different makes that I like it more in the VB.Net way, but just my opinion. Cor Show quoteHide quote "RobinS" <RobinS@NoSpam.yah.none> schreef in bericht news:m5KdnXqPNLBvAPXYnZ2dnUVZ_qmdnZ2d@comcast.com... >I agree! > > Robin S. > ------------------- > "Rad [Visual C# MVP]" <nospam@nospam.com> wrote in message > news:0h5hm2to3gvea04m3uidpst849fhc9kb4p@4ax.com... >> Oh my! >> >> VB.NET vs C# is a debate that is never going to have an end! >> >> Let us distill it to one simple maxim? >> >> Which language do you prefer? That one's the best >> >> On 25 Nov 2006 00:50:06 -0800, "Tom Shelton" <tom_shel***@comcast.net> >> wrote: >> >>> >>>RobinS wrote: >>>> There's a list of all the string and date manipulation >>> >>><snip> >>> >>>> The only gotcha is that it's probably for .Net 2002. But >>>> I still find it helpful when just looking for syntax diffs >>>> between VB.Net and C#.Net (I can't ever remember how to >>>> cast in C#, or implement interfaces. Sigh.) >>>> >>> >>>Really? If anything I think the VB.NET version of both is harder... >>>In fact, I like the C# as syntax when working with reference types >>>because you can avoid invalid cast exceptions and simply check for >>>null. >>> >>>The VB.NET way of interfaces is way to wordy for my taste - of course >>>it does have the nice side effect of allowing you to rename the >>>interface method... >> -- >> >> Bits.Bytes. >> http://bytes.thinkersroom.com > > I agree with you about the casting; it's so much clearer in VB.
I bought that data binding book by Brian Noyes, which is in C#, and it forced me to learn to translate. I had some trouble with the stuff that's way different, like event handlers, interfaces, and casting variables. But I can respect other people's opinions. (Unlike some trolls.) Robin S. ---------------------------------- Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:%23jYPdeNEHHA.4132@TK2MSFTNGP04.phx.gbl... > Robin, > > I was only tickling Tom, he is one of the longest regulars from the VB.Net > newsgroup.] > > For you the casting equivalent in c# is. > DirectCast is in C# x as myType > Ctype is in C# (myType) x > > That is so much different makes that I like it more in the VB.Net way, but > just my opinion. > > Cor > > "RobinS" <RobinS@NoSpam.yah.none> schreef in bericht > news:m5KdnXqPNLBvAPXYnZ2dnUVZ_qmdnZ2d@comcast.com... >>I agree! >> >> Robin S. >> ------------------- >> "Rad [Visual C# MVP]" <nospam@nospam.com> wrote in message >> news:0h5hm2to3gvea04m3uidpst849fhc9kb4p@4ax.com... >>> Oh my! >>> >>> VB.NET vs C# is a debate that is never going to have an end! >>> >>> Let us distill it to one simple maxim? >>> >>> Which language do you prefer? That one's the best >>> >>> On 25 Nov 2006 00:50:06 -0800, "Tom Shelton" <tom_shel***@comcast.net> >>> wrote: >>> >>>> >>>>RobinS wrote: >>>>> There's a list of all the string and date manipulation >>>> >>>><snip> >>>> >>>>> The only gotcha is that it's probably for .Net 2002. But >>>>> I still find it helpful when just looking for syntax diffs >>>>> between VB.Net and C#.Net (I can't ever remember how to >>>>> cast in C#, or implement interfaces. Sigh.) >>>>> >>>> >>>>Really? If anything I think the VB.NET version of both is harder... >>>>In fact, I like the C# as syntax when working with reference types >>>>because you can avoid invalid cast exceptions and simply check for >>>>null. >>>> >>>>The VB.NET way of interfaces is way to wordy for my taste - of course >>>>it does have the nice side effect of allowing you to rename the >>>>interface method... >>> -- >>> >>> Bits.Bytes. >>> http://bytes.thinkersroom.com >> >> > > Rad [Visual C# MVP] wrote:
> Oh my! I agree. I wasn't trying to start a debate. Just a friendly> > VB.NET vs C# is a debate that is never going to have an end! > > Let us distill it to one simple maxim? > > Which language do you prefer? That one's the best > discussion. -- Tom Shelton Rob,
The DateTime.ToString(IDateTimeprovider) gives you endless possibilities. http://msdn2.microsoft.com/en-us/library/ht77y576.aspx http://msdn2.microsoft.com/en-us/library/az4se3k1.aspx (They are already for years in the category most bad pages on MSDN). Beside that you can use the DateTime.ParseExact if you really have strange wishes. Be aware that that one makes your datetime representation direct local to a situation. Dates and times are very different written, by instance the USA, English Canada and French Canada have all three diferent notations of that. Cor Show quoteHide quote "Rob" <ro***@yahoo.com> schreef in bericht news:XsSdnYMGiPtd2PrYnZ2dnUVZ_vqdnZ2d@comcast.com... > In order to create a date in CCYY-MM-DD fashion, I used to be able to use > the Format(date,"yyyy")&"-"&Format(month,"mm")... syntax... > > This no longer appears to work in vb.net. I know how I could do this..., > by prepending a "0" to the month and taking the right 2 characters, but > that is silly. > > What is the new "easy" way ? > > Is there a list some where of all the string and date manipulation > functions with "old" and "new" methods somewhere ? > > Thanks ! >
Registry Key Manipulation
Need Help on String.Format() method Books for learning VB.NET Serialization Help!!!!!!!!!! Need help to marshall Win32 DLL call to VB.net Help reading simple text file Needto grab the name and position of all buttons on a form -is this possible? Beginners needs some help in Writing to text file help readin text file Want multiple copies of a DLL to run... |
|||||||||||||||||||||||