trouble with number rounding

324 views
Skip to first unread message

laurie

unread,
Sep 16, 2013, 12:31:02 PM9/16/13
to e-p...@googlegroups.com
Hello,

I am using a modified version of the "VisualScaleAnalog" script which is recording the position of a muse click on a scale.

Then it displays the recorded "score" to the user.

What the original script does is this

    Dim percent as Integer
    Mouse.GetCursorPos ptPress.X, ptPress.Y
    percent = 100*((ptPress.X-VAS_SliderDummy.Left)/sw)

    ...
    and then it displays "percent"


So the original script would display a score of "75" if the subject clicked on the 3/4th of the scale

What i want to display is something like "7.5" instead of "75".

I tried this :

    Dim percent as Integer
    Dim score as Double
    Mouse.GetCursorPos ptPress.X, ptPress.Y
    percent = 100*((ptPress.X-VAS_SliderDummy.Left)/sw)
    score=CInt(percent)/10
    ...
    and then display "score"


but then it would display something like "7.500121245" instead of just "7.5"
how can i format the score so that it shows to 1 or 2 decimal places?

thank you

Paul Groot

unread,
Sep 16, 2013, 2:56:00 PM9/16/13
to e-p...@googlegroups.com
The FOrmat function will be able to do this for you. (See the E-Basic help documentation for a complete description with examples)

score = Format$(percent/10,"0.0")

or

score = Format$(percent/10,"0.00")

for two decimals.

Paul


--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+u...@googlegroups.com.
To post to this group, send email to e-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/84487198-c5d1-49b3-8e8d-268eee77b9f2%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

laurie bayet

unread,
Sep 17, 2013, 9:18:24 AM9/17/13
to e-p...@googlegroups.com
thanks, it worked :-)

have a nice day,
laurie


2013/9/16 Paul Groot <pfc....@gmail.com>

--
You received this message because you are subscribed to a topic in the Google Groups "E-Prime" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/e-prime/YkmFEvxOlxA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to e-prime+u...@googlegroups.com.

To post to this group, send email to e-p...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages