Click here to Skip to main content
12,404,478 members (69,926 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# VB
Hi guys,

I'm having to translate some old VB code into C#, and I'm a bit stumped on this one set of statements. I don't need to know what the output string would be, just which route the code would take through this statement (and why!).

Select Case True
  Case Not IsNumeric(strValue)
    strValue = Format$(Now, "dd-mmm-yyyy")
  Case CDbl(strValue) = 0
    strValue = Format$(Now, "dd-mmm-yyyy")
  Case Else
    strValue = Format$(DateSerial(Left(strValue, 2), Mid(strValue, 3, 2), Right(strValue, 2)), "dd-mmm-yyyy")
End Select

The first two Case statements both return the same value regardless, so it makes no sense to me how I should really be translating this into C#. Any ideas?

Many thanks.
Posted 28-Dec-12 4:26am
Updated 28-Dec-12 4:30am
v4

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

if (!IsNumeric(strValue)){
    strValue = Format$(Now, "dd-mmm-yyyy")
} else if (strValue == 0){
    strValue = Format$(Now, "dd-mmm-yyyy")
} else {
    strValue = Format$(DateSerial(Left(strValue, 2), Mid(strValue, 3, 2), Right(strValue, 2)), "dd-mmm-yyyy")
}

Of course i didn't find the C# equivalent but you get the idea of how the code flows now.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100