Adding 2 numbers from variant array

grahamw

Registered User.
Local time
Today, 01:09
Joined
Aug 19, 2005
Messages
23
Good Evening.
There must be a very simple answer to this one- hopefully someone can help.
I want to add 2 numbers within a variant array- basically
track(46, 4) = (horse_n(1, (form_race - 1), 8)) + (horse_n(1, (form_race - 2), 8))
The two array values are 105 and 98.
I get an output of 10598 rather than 203.
I'm stumped?
Regards
Graham, London
 
Your variant array elements are behaving like strings. Try...
Code:
track(46, 4) = [COLOR=DarkRed]CLng[/COLOR](horse_n(1, (form_race - 1), 8)) + [COLOR=DarkRed]CLng[/COLOR](horse_n(1, (form_race - 2), 8))
 
worked..thanks lagbolt
Ive just typed the CLng command into access VB 'help' and it doesnt
detail this command. Also not mentioned in my Access book.
Can you recommend a source for such functions/commands.
(My VB access knowledge is reasonably limited at the moment)
Thanks.
 
From the Access Help File:

Type Conversion Functions


Each function coerces an expression to a specific data type.

Syntax

CBool(expression) - converts to Boolean

CByte(expression) - converts to Byte

CCur(expression) - converts to Currency

CDate(expression) - converts to a Date

CDbl(expression) - converts to a Double

CDec(expression) - converts to a Decimal

CInt(expression) - converts to Integer

CLng(expression) - converts to Long

CSng(expression) - converts to Single

CStr(expression) - converts to String

CVar(expression) - converts to a Variant
 
Graham,

VBA Help file keywords for the various conversion functions: Conversion, Type Conversion Functions

Regards,
Tim
 

Users who are viewing this thread

Back
Top Bottom