Convert values in a variant array to integer values

  • Thread starter Thread starter Graham McNeill
  • Start date Start date
G

Graham McNeill

I wish to add up certain values in a variant array (has to be variant, as
data is mixed), to make sure total of these values does not exceed 100. I
thought I could simply assign these array values to integer variables and
that would work, but it concatenates the numbers (12 + 4 = 124, for
instance) instead of adding them.

Any ideas how to do this?
 
Use
dim intAaccumulator as integer

'place this inside your loop to traverse the array
if isnumeric(array(counter).value) and instr(".", array(counter).value) = 0
then
intAccumulator = intAccumulator + (CInt(array(counter).value)
end if
 

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

Back
Top