One of the cooler features of higher level languages is the built-in support for the ever-so-common task of formatting numbers. The .NET Framework provides the rather ubiquitous String.Format() method to help out with formatting numbers, dates, and everything else. VB.NET makes it even easier, carrying over the Format() method from previous versions of visual basic. That said, Ant Day was a bit surprised to a plethora of examples like this in a VB.NET solution developed from a highly-paid consulting company that "adapts leading-edge technology, best practices, and experience to help customers realise their business objectives:"
If inputEmployeeNo.Length < 6 Then Select Case (inputEmployeeNo.Length) ' Evaluate userid. Case 1 inputEmployeeNo = "00000" & inputEmployeeNo Case 2 inputEmployeeNo = "0000" & inputEmployeeNo Case 3 inputEmployeeNo = "000" & inputEmployeeNo Case 4 inputEmployeeNo = "00" & inputEmployeeNo Case 5 inputEmployeeNo = "0" & inputEmployeeNo End Select End If
And before you try to blame Visual Basic, Dave Markle's colleague insists upon the same. I'll spare you the PrintDay and PrintYear functions ...
private string PrintMonth( int l_intMonthNum ) { switch (l_intMonthNum) { case 1: return "01"; case 2: return "02"; case 3: return "03"; case 4: return "04"; case 5: return "05"; case 6: return "06"; case 7: return "07"; case 8: return "08"; case 9: return "09"; case 10: return "10"; case 11: return "11"; case 12: return "12"; default: return ""; } }