Link to home
Start Free TrialLog in
Avatar of pvg1975
pvg1975Flag for Argentina

asked on

right function. Translation from VB 6 to .NET

Hi all,

How do I translate the following in ASP.NET?

XMonth= Right("00" & Month(now()), 2)

I tried

Dim XMonth as String = Right("00" & Month(Today), 2)

but its giving me an error on the right function

Thanks!
Avatar of kaufmed
kaufmed
Flag of United States of America image

XMonth= Right("00" & Month(Today), 2)
Well VB.NET ported all of those old-style function over, so your code still technically is valid. But if you're interested in making it more .NET-centric, then you could do something like:

XMonth = Today.Month.ToString("00")

Open in new window

When I say, "your code still technically is valid," I am referring to the old VB6 code (i.e. your first snippet), not the one I quoted. Sorry if it caused confusion.
Avatar of pvg1975

ASKER

Hey K

That will result in, for example 12 for december, 05 for may (not 5), 01 for june, etc?

Thanks!
Avatar of pvg1975

ASKER

Sorry I mean 01 for January :P
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pvg1975

ASKER

I cannot try it now, that's why I ask BTW :)
Avatar of pvg1975

ASKER

Thanks! I will try it as soon as Im back home. Thanks again! :)
No problem. Glad to help  = )

P.S.

Feel free to post back if you have any questions about the above.