Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • Leaders
Posted

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).

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

  • *Experts*
Posted

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

"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
Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...