Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 148
Default vba calcs are acting funny

I have a process with 42 pages of code. There are a boatload of calcs in it
that seem to be working.
However there is one that is giving me a hard time and I can't figure it out.
I have declarations: public overallscore as integer, public allscore as
integer, and public totalscore as integer, and public dataset as integer
I do not have any declarations for x.

OverAllScore = totalscore / dataset 'OverAllScore =0
x = totalscore / dataset ' x=-0.5
allscore = x 'allscore =0
If OverAllScore = 0.5 Then . . .

I am getting a value of -2 for totalscore and 4 for dataset. However
overallscore =0.
On the contrary x=-0.5 which is as expected. Then allscore ends up =0
instead of equal to x.

What am I possibly overlooking?

TIA


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default vba calcs are acting funny


"Papa Jonah" wrote in message
...
I have a process with 42 pages of code. There are a boatload of calcs in

it
that seem to be working.
However there is one that is giving me a hard time and I can't figure it

out.
I have declarations: public overallscore as integer, public allscore as
integer, and public totalscore as integer, and public dataset as integer
I do not have any declarations for x.

OverAllScore = totalscore / dataset 'OverAllScore =0
x = totalscore / dataset ' x=-0.5
allscore = x 'allscore =0
If OverAllScore = 0.5 Then . . .

I am getting a value of -2 for totalscore and 4 for dataset. However
overallscore =0.
On the contrary x=-0.5 which is as expected. Then allscore ends up =0
instead of equal to x.

What am I possibly overlooking?

TIA



Use Double rather than integer. And declare x as Double, too. If you divide
an integer value with another integer, the result will be an integer.

/Fredrik


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 148
Default vba calcs are acting funny

I am not sure I understand. Do you want me to decla
public x as double?
I understand that if I divide an integer by an integer, I get an integer -
so why don't I declare the result as an integer?

"Fredrik Wahlgren" wrote:


"Papa Jonah" wrote in message
...
I have a process with 42 pages of code. There are a boatload of calcs in

it
that seem to be working.
However there is one that is giving me a hard time and I can't figure it

out.
I have declarations: public overallscore as integer, public allscore as
integer, and public totalscore as integer, and public dataset as integer
I do not have any declarations for x.

OverAllScore = totalscore / dataset 'OverAllScore =0
x = totalscore / dataset ' x=-0.5
allscore = x 'allscore =0
If OverAllScore = 0.5 Then . . .

I am getting a value of -2 for totalscore and 4 for dataset. However
overallscore =0.
On the contrary x=-0.5 which is as expected. Then allscore ends up =0
instead of equal to x.

What am I possibly overlooking?

TIA



Use Double rather than integer. And declare x as Double, too. If you divide
an integer value with another integer, the result will be an integer.

/Fredrik



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default vba calcs are acting funny


"Papa Jonah" wrote in message
...
I am not sure I understand. Do you want me to decla
public x as double?


Yes. totalscore and dataset too

I understand that if I divide an integer by an integer, I get an integer -
so why don't I declare the result as an integer?


Becuse it doesn't make sense to compare an integer value with a decimal
value. That's what you do with "If OverAllScore = 0.5 Then . . . "

/Fredrik


"Fredrik Wahlgren" wrote:


"Papa Jonah" wrote in message
...
I have a process with 42 pages of code. There are a boatload of calcs

in
it
that seem to be working.
However there is one that is giving me a hard time and I can't figure

it
out.
I have declarations: public overallscore as integer, public allscore

as
integer, and public totalscore as integer, and public dataset as

integer
I do not have any declarations for x.

OverAllScore = totalscore / dataset 'OverAllScore =0
x = totalscore / dataset ' x=-0.5
allscore = x 'allscore =0
If OverAllScore = 0.5 Then . . .

I am getting a value of -2 for totalscore and 4 for dataset. However
overallscore =0.
On the contrary x=-0.5 which is as expected. Then allscore ends up =0
instead of equal to x.

What am I possibly overlooking?

TIA



Use Double rather than integer. And declare x as Double, too. If you

divide
an integer value with another integer, the result will be an integer.

/Fredrik





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 148
Default vba calcs are acting funny

I don't understand what "double" is supposed to represent, but it works.
Thanks

"Fredrik Wahlgren" wrote:


"Papa Jonah" wrote in message
...
I am not sure I understand. Do you want me to decla
public x as double?


Yes. totalscore and dataset too

I understand that if I divide an integer by an integer, I get an integer -
so why don't I declare the result as an integer?


Becuse it doesn't make sense to compare an integer value with a decimal
value. That's what you do with "If OverAllScore = 0.5 Then . . . "

/Fredrik


"Fredrik Wahlgren" wrote:


"Papa Jonah" wrote in message
...
I have a process with 42 pages of code. There are a boatload of calcs

in
it
that seem to be working.
However there is one that is giving me a hard time and I can't figure

it
out.
I have declarations: public overallscore as integer, public allscore

as
integer, and public totalscore as integer, and public dataset as

integer
I do not have any declarations for x.

OverAllScore = totalscore / dataset 'OverAllScore =0
x = totalscore / dataset ' x=-0.5
allscore = x 'allscore =0
If OverAllScore = 0.5 Then . . .

I am getting a value of -2 for totalscore and 4 for dataset. However
overallscore =0.
On the contrary x=-0.5 which is as expected. Then allscore ends up =0
instead of equal to x.

What am I possibly overlooking?

TIA



Use Double rather than integer. And declare x as Double, too. If you

divide
an integer value with another integer, the result will be an integer.

/Fredrik








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default vba calcs are acting funny

Double is one of the many data types that VBA and Excel understand. A
variable defined as an integer will only accept whole numbers between -32,762
and 32,767. If you try to assign the number 40,000 to an "interger" variable
you will have a problem. A variable defined as "double" accepts a much
larger range of numbers including decimals. There are many other variable
types also. You can look up VBA Data Types to find more details.

By the way, an integer divided by an integer is not always an integer. 5 /
2 = 2.5 which is not an integer.

Stan Shoemaker
Palo Alto, CA

"Papa Jonah" wrote:

I don't understand what "double" is supposed to represent, but it works.
Thanks

"Fredrik Wahlgren" wrote:


"Papa Jonah" wrote in message
...
I am not sure I understand. Do you want me to decla
public x as double?


Yes. totalscore and dataset too

I understand that if I divide an integer by an integer, I get an integer -
so why don't I declare the result as an integer?


Becuse it doesn't make sense to compare an integer value with a decimal
value. That's what you do with "If OverAllScore = 0.5 Then . . . "

/Fredrik


"Fredrik Wahlgren" wrote:


"Papa Jonah" wrote in message
...
I have a process with 42 pages of code. There are a boatload of calcs

in
it
that seem to be working.
However there is one that is giving me a hard time and I can't figure

it
out.
I have declarations: public overallscore as integer, public allscore

as
integer, and public totalscore as integer, and public dataset as

integer
I do not have any declarations for x.

OverAllScore = totalscore / dataset 'OverAllScore =0
x = totalscore / dataset ' x=-0.5
allscore = x 'allscore =0
If OverAllScore = 0.5 Then . . .

I am getting a value of -2 for totalscore and 4 for dataset. However
overallscore =0.
On the contrary x=-0.5 which is as expected. Then allscore ends up =0
instead of equal to x.

What am I possibly overlooking?

TIA



Use Double rather than integer. And declare x as Double, too. If you

divide
an integer value with another integer, the result will be an integer.

/Fredrik






Reply
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
Percentage Calcs Muskoka83 Excel Discussion (Misc queries) 1 May 17th 10 11:35 PM
Averageif Calcs Help Excel Discussion (Misc queries) 6 August 21st 09 02:19 PM
What are the calcs in PMT Micky G Excel Worksheet Functions 7 November 22nd 07 07:31 PM
Cell acting funny... Roz Excel Discussion (Misc queries) 3 January 6th 06 04:01 PM
VBA Acting "Funny" Shawn Shuler Excel Programming 2 August 6th 04 12:17 AM


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

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

About Us

"It's about Microsoft Excel"