Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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!).

VB
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
Updated 28-Dec-12 4:30am
v4

1 solution

C#
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900