JumpsInLava Posted June 8, 2004 Posted June 8, 2004 Logic check. Is this correct? Dim iMltryHour As Integer = 14 Dim iMltryMinute As Integer = 23 Dim iCvlnHour As Integer = 12 Dim iCvlnMinute As Integer = iMltryMinute Dim strCvlnAMPM As String = "AM" If iMltryHour = 0 Then iCvlnHour = "12" strCvlnAMPM = "AM" ElseIf iMltryHour < 12 Then iCvlnHour = iMltryHour strCvlnAMPM = "AM" ElseIf iMltryHour = 12 Then iCvlnHour= "12" strCvlnAMPM = "PM" Else iCvlnHour = iMltryHour - 12 strCvlnAMPM = "PM" End If Quote
Leaders Iceplug Posted June 8, 2004 Leaders Posted June 8, 2004 Yes, the logic looks fine, but you could: iCvlnHour = "12" ... use a integer 12, instead of a string literal "12" there. Also, there doesn't seem to be any need to initialize the civilian hour, minute, and AM/PM (which, by the way, you can use a Boolean instead). Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
*Experts* Nerseus Posted June 8, 2004 *Experts* Posted June 8, 2004 You don't need to write your own conversion, unless I'm missing something. Just use the appropriate ToString function: ' 6/8/2004 @ 14:33:31 or 2:33:31 PM Dim d1 As DateTime = new DateTime(2004, 6, 8, 14, 33, 31) Debug.WriteLine("Military: " + d1.ToString("HH:mm")) Debug.WriteLine("Civilian: " + d1.ToString("hh:mmtt")) (I manually typed in the VB code from C#, might not be 100%) -ners Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
JumpsInLava Posted June 8, 2004 Author Posted June 8, 2004 Doh! Thanks all. I guess I learned the hard way, and the easy way. :D You don't need to write your own conversion, unless I'm missing something. Just use the appropriate ToString function: ' 6/8/2004 @ 14:33:31 or 2:33:31 PM Dim d1 As DateTime = new DateTime(2004, 6, 8, 14, 33, 31) Debug.WriteLine("Military: " + d1.ToString("HH:mm")) Debug.WriteLine("Civilian: " + d1.ToString("hh:mmtt")) (I manually typed in the VB code from C#, might not be 100%) -ners Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.