![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Something is just not right and I can not figure it out, I need help the below is a line from a Do Loop routine I have and I'm trying to check how any characters there are after the decimal point. The CUnits field is defined as DataType=Number, FieldSize=Double, Format=Fixed, Decimals=2. On the input form first record for CUnits I enter .01 on the second record for CUnits I enter .1 if I open the table I see that the entered .01 is stored as 0.01 and the entered .1 is stored as 0.10 in Debug mode for the first record strLen = InStrRev(MyRec!CUnits, ".") if I hold the cursor over CUnits it shows -> .01 and strLen=2 movenext, loop if I hold the cursor over CUnits for the second record it shows -> 0.1 and strLen=2 which is what I don't understand, first, why is the debug mode display different of the two records? second, why is strLen 2 characters for this second record? help, thanks bobh. |
#3
| |||
| |||
|
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Man, don't worry about it. *You can display the number in any format using the Format() function and, if in a Control, the Format property: If number = .01 (actually stored as 0.01): * *Format(number, "#.##") = 0.01 * *Format(number, ".##") *= *.01 * *Format property: *".##" *will display as above. If the number = .1 (actually stored as 0.10): * *Format(number, "#.##") = 0.10 * *Format(number, ".#") * = *.1 HTH, -- MGFoster:::mgf00 <at> earthlink <decimal-point> net Oakland, CA (USA) ** Respond only to this newsgroup. *I DO NOT respond to emails ** -----BEGIN PGP SIGNATURE----- Version: PGP for Personal Privacy 5.0 Charset: noconv iQA/AwUBSXo4DYechKqOuFEgEQIH4ACePfCjPh83Hcs7B39YnmxIba NpLpEAn0Sv dzXX+yl7/fLjtsLntBfvcB5M =yUHk -----END PGP SIGNATURE----- bobhwrote: Something is just not right and I can not figure it out, I need help the below is a line from a Do Loop routine I have and I'm trying to check how any characters there are after the decimal point. The CUnits field is defined as DataType=Number, FieldSize=Double, Format=Fixed, Decimals=2. On the input form first record for CUnits I enter .01 on the second record for CUnits I enter .1 if I open the table I see that the entered .01 is stored as 0.01 and the entered .1 is stored as 0.10 in Debug mode for the first record strLen = InStrRev(MyRec!CUnits, ".") if I hold the cursor over CUnits it shows -> .01 and strLen=2 movenext, loop if I hold the cursor over CUnits for the second record it shows -> 0.1 and strLen=2 which is what I don't understand, first, why is the debug mode display different of the two records? second, why is strLen 2 characters for this second record? help, thanks bobh.- Hide quoted text - - Show quoted text - |
#4
| |||
| |||
|
|
On Jan 23, 4:35 pm, MGFoster <m... (AT) privacy (DOT) com> wrote: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Man, don't worry about it. You can display the number in any format using the Format() function and, if in a Control, the Format property: If number = .01 (actually stored as 0.01): Format(number, "#.##") = 0.01 Format(number, ".##") = .01 Format property: ".##" will display as above. If the number = .1 (actually stored as 0.10): Format(number, "#.##") = 0.10 Format(number, ".#") = .1 HTH, -- MGFoster:::mgf00 <at> earthlink <decimal-point> net Oakland, CA (USA) ** Respond only to this newsgroup. I DO NOT respond to emails ** -----BEGIN PGP SIGNATURE----- Version: PGP for Personal Privacy 5.0 Charset: noconv iQA/AwUBSXo4DYechKqOuFEgEQIH4ACePfCjPh83Hcs7B39YnmxIba NpLpEAn0Sv dzXX+yl7/fLjtsLntBfvcB5M =yUHk -----END PGP SIGNATURE----- bobhwrote: Something is just not right and I can not figure it out, I need help the below is a line from a Do Loop routine I have and I'm trying to check how any characters there are after the decimal point. The CUnits field is defined as DataType=Number, FieldSize=Double, Format=Fixed, Decimals=2. On the input form first record for CUnits I enter .01 on the second record for CUnits I enter .1 if I open the table I see that the entered .01 is stored as 0.01 and the entered .1 is stored as 0.10 in Debug mode for the first record strLen = InStrRev(MyRec!CUnits, ".") if I hold the cursor over CUnits it shows -> .01 and strLen=2 movenext, loop if I hold the cursor over CUnits for the second record it shows -> 0.1 and strLen=2 which is what I don't understand, first, why is the debug mode display different of the two records? second, why is strLen 2 characters for this second record? help, thanks bobh.- Hide quoted text - - Show quoted text - I wish I didn't have to worry about it but I do because this line is not evaluating correctly or as how I think it should. if I enter .1 as a value this line in my code will evaluate to a "2" in the strLen and it should be "1" so the if statement does not evaluate correctly strLen = InStrRev(MyRec!CUnits, ".") if strLen = 1 then tmp1 = InStrRev(MyRec!CUnits, ".") I need to know how many characters after the decimal point because if I were to add a whole number to the decimal part I need it to work out correctly. example: a whole number say - 60 + InStrRev(MyRec!CUnits, ".") would equal 61 and I need it to equal 70 since .1 equals 10 so, in the above case if the InStrRev would calculate correctly then I could strLen = InStrRev(MyRec!CUnits, ".") if strLen = 1 then tmp1 = InStrRev(MyRec!CUnits, ".") & 0 then tmp1 would have 10 and adding that to a value of 60 would equal 70 bobh. |
#5
| |||
| |||
|
|
bobh wrote: On Jan 23, 4:35 pm, MGFoster <m... (AT) privacy (DOT) com> wrote: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Man, don't worry about it. *You can display the number in any format using the Format() function and, if in a Control, the Format property: If number = .01 (actually stored as 0.01): * Format(number, "#.##") = 0.01 * Format(number, ".##") *= *.01 * Format property: *".##" *will display as above. If the number = .1 (actually stored as 0.10): * Format(number, "#.##") = 0.10 * Format(number, ".#") * = *.1 HTH, -- MGFoster:::mgf00 <at> earthlink <decimal-point> net Oakland, CA (USA) ** Respond only to this newsgroup. *I DO NOT respond to emails ** -----BEGIN PGP SIGNATURE----- Version: PGP for Personal Privacy 5.0 Charset: noconv iQA/AwUBSXo4DYechKqOuFEgEQIH4ACePfCjPh83Hcs7B39YnmxIba NpLpEAn0Sv dzXX+yl7/fLjtsLntBfvcB5M =yUHk -----END PGP SIGNATURE----- bobhwrote: Something is just not right and I can not figure it out, I need help the below is a line from a Do Loop routine I have and I'm trying to check how any characters there are after the decimal point. The CUnits field is defined as DataType=Number, FieldSize=Double, Format=Fixed, Decimals=2. On the input form first record for CUnits I enter .01 on the second record for CUnits I enter .1 if I open the table I see that the entered .01 is stored as 0.01 and the entered .1 is stored as 0.10 in Debug mode for the first record strLen = InStrRev(MyRec!CUnits, ".") if I hold the cursor over CUnits it shows -> .01 and strLen=2 movenext, loop if I hold the cursor over CUnits for the second record it shows -> 0.1 and strLen=2 which is what I don't understand, first, why is the debug mode display different of the two records? second, why is strLen 2 characters for this second record? help, thanks bobh.- Hide quoted text - - Show quoted text - I wish I didn't have to worry about it but I do because this line is not evaluating correctly or as how I think it should. if I enter * *.1 * as a value this line in my code will evaluate to a "2" in the strLen and it should be "1" so the if statement does not evaluate correctly strLen = InStrRev(MyRec!CUnits, ".") if strLen = 1 then tmp1 = InStrRev(MyRec!CUnits, ".") I need to know how many characters after the decimal point because if I were to add a whole number to the decimal part I need it to work out correctly. example: a whole number say - 60 + InStrRev(MyRec!CUnits, ".") would equal 61 and I need it to equal 70 since .1 equals 10 *so, in the above case if the InStrRev would calculate correctly then I could strLen = InStrRev(MyRec!CUnits, ".") if strLen = 1 then tmp1 = InStrRev(MyRec!CUnits, ".") & 0 then tmp1 would have 10 and adding that to a value of 60 would equal 70 bobh. Could you use Cstr() Num = 123.4567 ? Num * 123.4567 Num = 12.34 ? Instr(cstr(num),".") * 3 Num = 1 ? Instr(cstr(num),".") * 0 Expanding this Num = 123.4567 ? num * 123.4567 ? len(Cstr(num)) -Instr(cstr(num),".") * 4 Num = 12.345 ? len(Cstr(num)) -Instr(cstr(num),".") * 3 What if the number is an integer Num = 1 ? len(Cstr(num)) -Instr(cstr(num),".") * 1 ? len(Cstr(num)) - IIF(Instr(cstr(num),".") > 0 , Instr(cstr(num),"."), Len(cstr(num))) * 0 Would this help?- Hide quoted text - - Show quoted text - |
![]() |
| Thread Tools | |
| Display Modes | |
| |