Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() "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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() "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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Percentage Calcs | Excel Discussion (Misc queries) | |||
Averageif Calcs | Excel Discussion (Misc queries) | |||
What are the calcs in PMT | Excel Worksheet Functions | |||
Cell acting funny... | Excel Discussion (Misc queries) | |||
VBA Acting "Funny" | Excel Programming |