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.
Private Function TimeDifferenceInMins(ByVal intHours As Integer, ByVal intMinutes As Integer, ByVal intHours2 As Integer, ByVal intMinutes2 As Integer) As Integer
Dim MinIn1 As Integer = MinutesIn(intHours, intMinutes)
Dim MinIn2 As Integer = MinutesIn(intHours2, intMinutes2)
' Return MinIn1 - MinIn2 = intTimeDiff : This line is problematic.
' It returns the result of the comparison between MinIn1 - MinIn2 and intTimeDiff as an integer,
' when false it returns 0 and when true it returns -1
' So you need to return just MinIn1 - MinIn2 , so it should be
Return MinIn1 - MinIn2
End Function
The second one is:
VB Code:
Private Function MinutesIn(ByVal intHours As Integer, ByVal intMinutes As Integer) As Integer
Dim MinIn1 As Integer
Try
MinIn1 = (intHours * 60) + intMinutes
Return MinIn1
Catch ex As Exception
MsgBox("An Error Has Occurred: " & ex.Message, MsgBoxStyle.Information, "Time time time")
End Try
'Dim MinIn2 As Integer
'Try
' MinIn2 = (intHours * 60) + intMinutes
' Return MinIn2
'Catch ex As Exception
' MsgBox("An Error Has Occurred: " & ex.Message, MsgBoxStyle.Information, "Time time time")
'End Try
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