ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple addition problem (https://www.excelbanter.com/excel-programming/387947-simple-addition-problem.html)

[email protected]

Simple addition problem
 
Hello, I've got this line of code:

iVarOutRight(iNumVar) = iVarOutCol(iNumVar) + iVarOutWidth(iNumVar)

Simple enough you'd have thought, but it's assuming the values are
strings when they are integers as it is concatenating them, for
example:

5 + 60 = 560

How do I get it to just add them up to give 65 as the result (for
example)?

Thanks!


[email protected]

Simple addition problem
 
Sorry, I worked it out, using:

iVarOutWidth(iNumVar) = CInt(iVarOutWidth(iNumVar))
iVarOutCol(iNumVar) = CInt(iVarOutCol(iNumVar))

If there's a better way let me know, thanks.



JE McGimpsey

Simple addition problem
 
How are iVarOutCol() and iVaroutWidth() declared/assigned?

If they're both declared/assigned as String, you'll get the
concatenation.



In article .com,
" wrote:

Hello, I've got this line of code:

iVarOutRight(iNumVar) = iVarOutCol(iNumVar) + iVarOutWidth(iNumVar)

Simple enough you'd have thought, but it's assuming the values are
strings when they are integers as it is concatenating them, for
example:

5 + 60 = 560

How do I get it to just add them up to give 65 as the result (for
example)?

Thanks!



All times are GMT +1. The time now is 05:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com