Results 1 to 5 of 5

Thread: Help Please

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2003
    Posts
    23

    Help Please

    Good Evening,
    I am currently taking a VB.NET class. We had a lab due last Sunday and mine is not doing what it is supposed to and I am not for sure why. Can anyone please help me look at my code to figure out how it will calculate the numbers correctly? It is supposed to have 4 input boxes asking for hours and minutes and then take the numbers and convert them all to minutes and subtract the second set of hours and minutes from the first set. I have asked some of the people in my class, but most of them have no clue either and the ones that are finished are going on to this weeks work. I feel like if I do not find out why it is not working than I have not accomplished anything. Thank you in advance for any responses.

    JAZ
    Attached Files Attached Files

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    At least two problems in your code:
    First:
    VB Code:
    1. Private Function TimeDifferenceInMins(ByVal intHours As Integer, ByVal intMinutes As Integer, ByVal intHours2 As Integer, ByVal intMinutes2 As Integer) As Integer
    2.         Dim MinIn1 As Integer = MinutesIn(intHours, intMinutes)
    3.         Dim MinIn2 As Integer = MinutesIn(intHours2, intMinutes2)
    4.         ' Return MinIn1 - MinIn2  = intTimeDiff : This line is problematic.
    5.         ' It returns the result of the comparison between MinIn1 - MinIn2  and  intTimeDiff as an integer,
    6.         ' when false it returns 0 and when true it returns -1
    7.         ' So you need to return just MinIn1 - MinIn2  , so it should be
    8.         Return MinIn1 - MinIn2  
    9. End Function
    The second one is:
    VB Code:
    1. Private Function MinutesIn(ByVal intHours As Integer, ByVal intMinutes As Integer) As Integer
    2.         Dim MinIn1 As Integer
    3.         Try
    4.             MinIn1 = (intHours * 60) + intMinutes
    5.             Return MinIn1
    6.         Catch ex As Exception
    7.             MsgBox("An Error Has Occurred: " & ex.Message, MsgBoxStyle.Information, "Time time time")
    8.         End Try
    9.         'Dim MinIn2 As Integer
    10.         'Try
    11.         '    MinIn2 = (intHours * 60) + intMinutes
    12.         '    Return MinIn2
    13.         'Catch ex As Exception
    14.         '    MsgBox("An Error Has Occurred: " & ex.Message, MsgBoxStyle.Information, "Time time time")
    15.         'End Try
    16. End Function
    The commented part is not needed at all.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2003
    Posts
    23
    Thank you for your time. I will make those changes and try it again. I appreciate you helping.
    JAZ

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Sep 2003
    Posts
    23

    Wink Thank you

    It works like it should. Thank you.
    JAZ

  5. #5
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Welcome
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width