Adding 2 numbers from variant array (1 Viewer)

grahamw

Registered User.
Local time
Today, 14:28
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
 

MarkK

bit cruncher
Local time
Today, 14:28
Joined
Mar 17, 2004
Messages
8,187
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))
 

grahamw

Registered User.
Local time
Today, 14:28
Joined
Aug 19, 2005
Messages
23
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.
 

boblarson

Smeghead
Local time
Today, 14:28
Joined
Jan 12, 2001
Messages
32,059
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
 

pono1

Registered User.
Local time
Today, 14:28
Joined
Jun 23, 2002
Messages
1,186
Graham,

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

Regards,
Tim
 

Users who are viewing this thread

Top Bottom