VB 6 ABS equivlent

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
 
M

Michel Posseth [MCP]

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
 
A

Armin Zingler

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top