Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VB Script for '/' and 'mod'
#1
Solved: 11 Years, 3 Months ago Question 
can any body help me in the given script

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


Thanks
sandhya

Reply
#2
Solved: 11 Years, 3 Months ago
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
Reply
#3
Solved: 11 Years, 3 Months ago
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
Reply
#4
Solved: 11 Years, 3 Months ago
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
Reply
#5
Solved: 11 Years, 3 Months ago
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.
Reply
#6
Solved: 11 Years, 3 Months ago
ThanQ very much both of u Ankesh and vIns.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)