Thread: Brain teaser of the day

1. Brain teaser of the day

User MArk B. (mkbutler@russellmellon.com.nospam) posted:

So, what's going on here? Run it and try to figure it out.

Don't post the answer until people have had a bit of time to figure it out.
(A day or two.) Email me directly if you can't wait to prove you got it
right.

This code is used to figure out what row in a calendar control that the date
we want to click on is in
A couple of days from the prior month are displayed on the control. That is
stored in the variable "iDaysFromPriorMonth". The day of the current month
we want to click is stored in the variable "iDayToClick". In this example,
that day is the 25th.
You can see a calendar that matches the example by looking for Saturday,
December 25th, 1999.

'----------------------------------------------------------------------
Sub Main
Dim Result As Integer
Dim iDaysFromPriorMonth As Integer
Dim iDayToClick As Integer
iDaysFromPriorMonth = 3
iDayToClick = 25

Result = (((iDaysFromPriorMonth + iDayToClick) - _
((iDaysFromPriorMonth + iDayToClick) Mod 7))/7) + 1
MsgBox Result

MsgBox (((iDaysFromPriorMonth + iDayToClick) - _
((iDaysFromPriorMonth + iDayToClick) Mod 7))/7) + 1

End Sub
'----------------------------------------------------------------------

MArk B.

Hint:
MsgBox ((((iDaysFromPriorMonth + iDayToClick) - _
((iDaysFromPriorMonth + iDayToClick) Mod 7))/7) + 1)
---

2. Re: Brain teaser of the day

This is the best question i have ever noticed in rational robot.

In My view the second one differs from the first one as the Msgbox statment takes the second parameter for the button type to be displayed

eg:Msgbox (i+i1) +1
will display the value of (i+i1) but not i+i1+1.

Anway thanks for this question.

Regards,
Vinayak Kamath
QA Analyst

------------------

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.