Click here to Skip to main content
Rate this: bad
good
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
Edited 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
0 Sergey Alexandrovich Kryukov 716
1 OriginalGriff 442
2 Tadit Dash 400
3 sanket saxena 337
4 Peter Leow 228
0 Sergey Alexandrovich Kryukov 11,890
1 OriginalGriff 7,335
2 Peter Leow 5,003
3 Abhinav S 3,943
4 Maciej Los 3,575


Advertise | Privacy | Mobile
Web04 | 2.8.140421.2 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid