Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Codes do not work in EXE
Message
From
20/09/2005 05:42:14
 
 
To
20/09/2005 04:18:39
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows '98
Network:
Windows 98
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01051157
Message ID:
01051174
Views:
9
Tariq,

Sorry, I can’t answer your question, but here is some advice that might give you more answers from other UT members and make your code more readable. You may or may not agree:

1. Give your variables meaningful names. Other people will have trouble reading your code, because they will have to scroll back to the top of the page to find out what a particular value is supposed to hold. I have taken the liberty to rewrite your code a bit. I think this is easier to understand.
2. Avoid naming variables the same names as reserved words.
3. Put in some comments in code. What are you trying to achieve?
4. Refer to what errors you are getting.
IF !empty(thisform.container3.text1.value)
	ldStart=thisform.container3.text1.value
	thisform.container3.text3.value=cdow(thisform.container3.text1.value)

	lnYearCount=0
	IF !EMPTY(ldStart)
		IF ldStart>DATE()
			RETURN .f.
		ENDIF

		lnStartDay=DAY(ldStart)
		lnStartMonth=MONTH(ldStart)
		lnStartYear=YEAR(ldStart)

		lnTodayDay=DAY(DATE())
		lnTodayMonth=MONTH(DATE())
		lnTodayYear=YEAR(DATE())

		lnYearCount=lnTodayYear-lnStartYear
		lnYearCount=IIF(lnStartMonth>lnTodayMonth,lnYearCount-1,IIF((lnStartMonth=lnTodayMonth) .and. (lnStartDay>lnTodayDay),lnYearCount-1,lnYearCount))
		lnMonthCount=lnTodayMonth-lnStartMonth

		IF lnStartDay>lnTodayDay
			lnMonthCount=lnMonthCount-1
		ENDIF
		IF lnMonthCount<0
			lnMonthCount=lnMonthCount+12
		ENDIF

		lnDayCount=lnTodayDay-lnStartDay

		DO CASE
		CASE INLIST(lnStartMonth,1,3,5,7,8,10,12)
			lnLastDayOfMonth=31
		CASE INLIST(lnStartMonth,4,6,9,11)
			lnLastDayOfMonth=30

		CASE lnStartMonth=2
			IF MOD(lnStartYear,400)=0
				lnLastDayOfMonth=29

			ELSE
				IF MOD(lnStartYear,100)=0
					lnLastDayOfMonth=28
				ELSE
					IF MOD(lnStartYear,4)=0
						lnLastDayOfMonth=29
					ELSE
						lnLastDayOfMonth=28
					ENDIF
				ENDIF
			ENDIF
		ENDCASE

		IF lnDayCount<0
			lnDayCount=lnDayCount+lnLastDayOfMonth
		ENDIF
	ENDIF

	thisform.container3.text2.value=alltrim(str(lnDayCount))+;
		+alltrim("-")+alltrim(str(lnMonthCount))+alltrim("-")+;
		alltrim(str(lnYearCount))
ENDIF
>Dear Experts
>
>Following codes work fine without Exe and do not work in EXE.
>What is wrong?
>Please help
>
>IF !empty(thisform.container3.text1.value)
>	b_date=thisform.container3.text1.value
>	thisform.container3.text3.value=cdow(thisform.container3.text1.value)
>
>	y_ears=0
>	IF !EMPTY(b_date)
>		IF b_date>DATE()
>			RETURN .f.
>		ENDIF
>
>		db=DAY(b_date)
>		mb=MONTH(b_date)
>		yb=YEAR(b_date)
>
>		dd=DAY(DATE())
>		MD=MONTH(DATE())
>		yd=YEAR(DATE())
>
>		y_ears=yd-yb
>		y_ears=IIF(mb>md,y_ears-1,IIF((mb=md) .and. (db>dd),y_ears-1,y_ears))
>		m_onths=md-mb
>
>		IF db>dd
>			m_onths=m_onths-1
>		ENDIF
>		IF m_onths<0
>			m_onths=m_onths+12
>		ENDIF
>
>		d_ays=dd-db
>
>		DO CASE
>		CASE INLIST(mb,1,3,5,7,8,10,12)
>			d_calc=31
>		CASE INLIST(mb,4,6,9,11)
>			d_calc=30
>
>		CASE mb=2
>			IF MOD(yb,400)=0
>				d_calc=29
>
>			ELSE
>				IF MOD(yb,100)=0
>					d_calc=28
>				ELSE
>					IF MOD(yb,4)=0
>						d_calc=29
>					ELSE
>						d_calc=28
>					ENDIF
>				ENDIF
>			ENDIF
>		ENDCASE
>
>		IF d_ays<0
>			d_ays=d_ays+d_calc
>		ENDIF
>	ENDIF
>
>	thisform.container3.text2.value=alltrim(str(d_ays))+;
>		+alltrim("-")+alltrim(str(m_onths))+alltrim("-")+;
>		alltrim(str(y_ears))
>ENDIF
>
>THISFORM.REFRESH
>
Previous
Reply
Map
View

Click here to load this message in the networking platform