VB 6 ABS equivlent

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

hi,
what would be vb.net equivlent to vb 6 abs function
for example
datediff(dateinterval.day,#11/1/2008#,#10/1/2008#) returns -31
if the date were reversed it would be 31
either way.. I want 31 to be the answer
 
returns -31
if the date were reversed it would be 31
either way.. I want 31 to be the answer

Simple solution could be

Dim ret as integer =datediff(dateinterval.day,#11/1/2008#,#10/1/2008#)
if ret <0 then ret=ret * -1

as math rules say - * - = + :-)

regards
Michel Posseth
 
Brian said:
hi,
what would be vb.net equivlent to vb 6 abs function
for example
datediff(dateinterval.day,#11/1/2008#,#10/1/2008#) returns -31 if
the date were reversed it would be 31
either way.. I want 31 to be the answer


Dim days As Integer

days = CInt(Math.Abs(#11/1/2008#.Subtract(#10/1/2008#).TotalDays))


Armin
 
Back
Top