simple format question

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

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 !
 
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.
 
RobinS said:
There's a list of all the string and date manipulation

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,

I don't like those C# evangelists in this newsgroup.

:-)

Are you a newbie wanting a war?

:-)

Cor
 
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
 
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.
------------------
 
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
 
I agree!

Robin S.
-------------------
Rad said:
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
 
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 said:
I agree!

Robin S.
 
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.
----------------------------------
Cor Ligthert said:
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
 
Cor said:
Tom,

I don't like those C# evangelists in this newsgroup.

:-)

Cor, I'm not evangelizing :) I like VB.NET - I just happen to like the
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 :)
 
RobinS said:
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 :)
 
Rad said:
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

I agree. I wasn't trying to start a debate. Just a friendly
discussion.
 
Tom Shelton said:
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 :)

Oh, no, I didn't think you meant any offense by your comments.
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.
 
Back
Top