ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Type change in a declared Variable? (https://www.excelbanter.com/excel-programming/379306-re-type-change-declared-variable.html)

Alok

Type change in a declared Variable?
 
Hi,
Seems like lCreditSum has been declared as a variant? Please check again. If
so you must declare it as Single or Currency.
Alok

"RjS, CISSP, CISA" wrote:

Hi - I have a VB program I wrote for excell some months ago. It has been
processing a bank report every day without a hitch for all that time. Today
it produced an entirely different and erroneous result. I traced the error to
the following statement:

lCreditSum = lCreditSum + wsSRC.Cells(i, 13).Value

Where lCreditSum is previously declared as a type Single. The SRC value is
formatted as a number with 2 decimal points. When I set a watch on the
lCreditSum variable and process a previous input report, its type assignment
remains as type Single throughout the entire run, but when it processes
todays input report the type assignment changes to a "Variant/String" on the
very first assignment. It then proceeds to append each new value to the
variable instead of adding the new values to the sum as its supposed to.

Please, anybody... any suggestions? Absolutely nothing has changed with this
program for several months and I have examined in input reports in minute
detail and can detect no changes.

Thanks much,



All times are GMT +1. The time now is 10:41 PM.

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