Micro Focus QTP (UFT) Forums
VB Script for '/' and 'mod' - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: VB Script for '/' and 'mod' (/Thread-VB-Script-for-and-mod)



VB Script for '/' and 'mod' - sandya.qtp - 10-13-2011

can any body help me in the given script

Script for Quotient and Reminder without using '/' operator and 'mod' function.


Thanks
sandhya




RE: VB Script for '/' and 'mod' - v.swaminathan - 10-17-2011

Hi Sandhya,
Can you let me know as why you do not want to use "/" or MOD in getting these results?

Thanks and Regards,
Swami


RE: VB Script for '/' and 'mod' - Ankesh - 10-17-2011

Hi Sandya,

I have did a sample coding for ur requirement and it is working now. Below is the code which u can use.


Code:
intVar1=56
intOriginalVar1Value=56 ' Keeping the original value for later use
intVar2=8
intOriginalVar2Value=8  ' Keeping the original value for later use
intQuotient =1

While  intVar1 > intVar2
    intVar1=intVar1-intVar2
    intQuotient=intQuotient+1
    

Wend
intReminder = intOriginalVar1Value - (intOriginalVar2Value*intQuotient)
msgbox intQuotient
msgbox intReminder

Do let me know if u have any query.

Regards,
Ankesh


RE: VB Script for '/' and 'mod' - vIns - 10-18-2011

Excellent idea Ankesh.

But it looks like it will give correct results only if intVar1 > intVar2.
Say my requirement is to find the Quotient & reminder for 3 / 8.
I would expect Quotient to be 0 and Reminder to be 3.
But it will return 1 and -5.
so..there is a small correction...i think it will work for all...

Code:
intVar1 = 3
intVar2 = 8

intQuotient = 0

While intVar1 >= intVar2
          intVar1=intVar1-intVar2
          intQuotient=intQuotient+1
Wend

msgbox "Quotient=" & intQuotient
msgbox "Reminder=" & intVar1



RE: VB Script for '/' and 'mod' - Ankesh - 10-18-2011

Hi Vins,

The code which i posted was jsut a sample code to meet the objective. It was just a piece from the perfect code.

Regards,
Ankesh


Thanks for updating the code vIns.


RE: VB Script for '/' and 'mod' - sandya.qtp - 10-18-2011

ThanQ very much both of u Ankesh and vIns.