Answered by:
Don't want rounded value
Question

User1992938117 posted
Hi,
i am using coding in vb.net and i want some values as
min=110 (integer Variable)
If (min > 59) Thenhrs = hrs + (min / 60.0)min = min Mod 60'min = tmin  fmin'p = hrs.ToString() + min.ToString()'Else' p = Val(tb3.Text)  Val(tb2.Text)End IfIf (min > 59) Then
fmin = (min / 60)
' Here i want fmin=1 instead of 2 ( fmin is integer)
min = min Mod 60
' Here i want min=50
End If
Over All Scenario is 
from time in textbox = 1755 and in to time=0455
output would be (total time = to time  from time) 1250
its just a example user can enter any time duration in text boxes as 0445 to 1859 etc etc......
All scenario is here just try to solve out my first query and if any one has idea regarding whole problem then really appreciated ............!!!!!!!!
Thanks...
Thursday, November 26, 2009 4:47 PM
Answers

User289219499 posted
Not sure what your trying to achieve, there are some good TimeSpan functions in .Net to get numbers or parts out.
But that said, one possible way to answer your problem is to make fmin a double then truncate it?
For example
Dim min As Integer = 110 Dim fmin As Double If (min > 59) Then ' THis give you 1.8 fmin = (min / 60) ' lets get just the whole number, which is 1 fmin = Math.Truncate(fmin) End If
hth,
Steve
 Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, November 26, 2009 5:00 PM
All replies

User289219499 posted
Not sure what your trying to achieve, there are some good TimeSpan functions in .Net to get numbers or parts out.
But that said, one possible way to answer your problem is to make fmin a double then truncate it?
For example
Dim min As Integer = 110 Dim fmin As Double If (min > 59) Then ' THis give you 1.8 fmin = (min / 60) ' lets get just the whole number, which is 1 fmin = Math.Truncate(fmin) End If
hth,
Steve
 Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, November 26, 2009 5:00 PM 
User952121411 posted
I think that mathmatical Algorithm is not needed based on how I am understanding your question. You can easily just take those values entered by the user and parse them into a DateTime object. From there you can subtract or add time quite easily (using .Subtract() or .Add()).
DateTime Structure:
http://msdn.microsoft.com/enus/library/system.datetime.aspx
Tuesday, December 1, 2009 5:11 PM