Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Compute vacation
Message
 
To
04/10/2004 08:30:28
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00948387
Message ID:
00948435
Views:
17
You are right again.
I just gave ther method how to do that. The Mohammed's choice is where to put that code.



>Adding this method to a form means you will end up with copies of this code in multiple forms. Making it part of a form class artificially bloats the class. Either a separate PRG or a calendar object with this as a method would be good choices, IMO.
>
>>Yes You can:
>>1. Add a method in Your form named CalculateDays
>>2. Add the followin code in that method:
>>
>>  LPARAMETERS startdate, enddate
>>  LOCAL cycle, tocycle, testdate, ret_val
>>  ret_val = 0
>>  tocycle = enddate-startdate
>>  FOR cycle = 0 TO tocycle
>>      testdate = startdate + cycle
>>      IF .NOT. INLIST(DOW(ScanDay,1), 6, 7)  && friday, saturday
>>         ret_val = ret_val + 1
>>      ENDIF
>>  ENDFOR
>>
>>RETURN ret_val
>>
>>
>>3. Change the lastline of Yourcode:
>>
>>thisform.text3.value=thisform.CalculateDays(thisform.text1.value,thisform.text2.value)
>>
>>
>>
>>BTW neither Function not Method or procedure can Have parameters with names thisform.xxxx
>>So You can't change FUNCTION xxx(startdate, enddate) to FUNCTION xxx(thisform.text1.Value, thisform.Text2.Value), or
>>LPARAMETERS thisform.text1.Value, thisform.Text2.Value
>>
>>
>>
>>
>>
>>>hi,
>>>thank you very much,
>>>
>>>but i don't know how i can use it at myform.
>>>
>>>can i change code as under
>>>
>>>*thisform.text1.value=startdate
>>>*thisform.text2.value=enddate
>>>thisform.text3.value=CalculateDays(thisform.text1.value,thisform.text2.value)
>>>
>>>
>>>FUNCTION CalculateDays(thisform.text1.value, thisform.text2.value)
>>>  LOCAL cycle, tocycle, testdate, ret_val
>>>  ret_val = 0
>>>  tocycle = enddate-startdate
>>>  FOR cycle = 0 TO tocycle
>>>      testdate = thisform.text1.value+cycle
>>>      IF .NOT. INLIST(DOW(ScanDay,1), 6, 7)  && friday, saturday
>>>         ret_val = ret_val + 1
>>>      ENDIF
>>>  ENDFOR
>>>
>>>RETURN ret_val
>>>
>>>
>>>
>>>thanks,
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform