LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Type change in a declared Variable?

At a guess, do you have declaration like :
Dim lCreditSum, MySingleVar as single

If so, this ONLY declares "MySingleVar" as a single ; "lCreditSum" is the
default for undeclared variables - Variant.
You need to explicitly state the datatype of each variable.

Dim lCreditSum As Single, MySingleVar as Single

NickHK

<RjS; <CISSP; "CISA" wrote in
message ...
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,



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reference a variable declared in VBA James Excel Worksheet Functions 3 September 12th 08 10:31 PM
Type change in a declared Variable? Martin Fishlock Excel Programming 0 December 13th 06 01:30 AM
Type change in a declared Variable? Gary''s Student Excel Programming 0 December 13th 06 01:23 AM
Type change in a declared Variable? Alok Excel Programming 0 December 13th 06 01:20 AM
Get an object's type if it's declared as Variant [email protected] Excel Programming 1 October 6th 06 07:52 AM


All times are GMT +1. The time now is 09:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"