I’ve been using the following to convert an Integer to a Double:
Val(Str(i))
where i is an Integer.
Is there a more direct way to do this? I need to convert an Integer occasionally to a Double to use Format.
I’ve been using the following to convert an Integer to a Double:
Val(Str(i))
where i is an Integer.
Is there a more direct way to do this? I need to convert an Integer occasionally to a Double to use Format.
dim i as integer = 5
dim d as double = i
msgbox str(d)
Format accepts either a Double or an Integer. No conversion required.
Any function that accepts a Double will also accept an Integer.
In general, Integer converts automatically to Double. That makes it hard to distinguish the two, but makes it easy to code.
[quote=353902:@Tim Hare]Format accepts either a Double or an Integer. No conversion required.
Any function that accepts a Double will also accept an Integer.
In general, Integer converts automatically to Double. That makes it hard to distinguish the two, but makes it easy to code.[/quote]
Well, well. I thought I always found the compiler complaining about using an Integer in the Format function, but now I see it’s fine with it. Not sure what I was doing in the past that made me think that. Thanks as usual, Tim.