>Anyone knows how I can speed up my form?
>
>I have a one-many form with the 'many' part implemented using pageframe. The maximum no. of pages is 11. At the moment, as the user navigates through the records, I add and remove pages.
>
>I have a pageframe class with new properties such as npagecnt, npageid. The controls on the pages are passed in as a class while adding page. There are about 15 textboxes, 5 combo boxes and 1 listbox on the control class.
>
>In my add page function, I do the following:
>
>PARAMETERS cPageClass, cPageCaption
>THIS.npagecnt = THIS.npagecnt + 1
>THIS.PAGECOUNT = THIS.npagecnt
>THIS.npageid = THIS.npageid + 1
>cPage = 'Page'+ALLTRIM(STR(THIS.npagecnt))
>THIS.&cPage..CAPTION = cPageCaption
>objname = 'Page'+ALLTRIM(STR(THIS.nPageID))
>THIS.&cPage..ADDOBJECT(objname,cPageClass)
>THIS.&cPage..&objname..visible = .T.
>
>In my remove page function, my codes are as follow:
>
>PARAMETERS cPageNo
>THIS.Pages(cPageNo).PAGEORDER = THIS.npagecnt
>THIS.npagecnt = THIS.npagecnt - 1
>THIS.PAGECOUNT = THIS.npagecnt
>
>Do you think defining page class (with the controls in in) in codes will speed up the form?
>
>Any other suggestions?
1)Use memvars as much as possible, they are much faster than property values. Perhaps you could declare m.nextpage public and initialize it to 1, then your add page function could be something like...
PARAMETERS cPageClass, cPageCaption
THIS.npagecnt = m.nextpage
THIS.PAGECOUNT = m.nextpage
THIS.npageid = m.nextpage
cPage = 'Page'+ALLTRIM(STR(m.nextpage))
THIS.&cPage..CAPTION = cPageCaption
objname = 'Page'+ALLTRIM(STR(m.nextpage))
THIS.&cPage..ADDOBJECT(objname,cPageClass)
THIS.&cPage..&objname..visible = .T.
m.nextpage=m.nextpage+1
2) You may have some funtional duplication in nPageCnt, PageCount and nPageId. Look into to removing or possibly ignoring duplicates for example
PARAMETERS cPageClass, cPageCaption
****THIS.npagecnt = m.nextpage
THIS.PAGECOUNT = m.nextpage
****THIS.npageid = m.nextpage
cPage = 'Page'+ALLTRIM(STR(m.nextpage))
THIS.&cPage..CAPTION = cPageCaption
objname = 'Page'+ALLTRIM(STR(m.nextpage))
THIS.&cPage..ADDOBJECT(objname,cPageClass)
THIS.&cPage..&objname..visible = .T.
m.nextpage=m.nextpage+1
3) And of course the slowest of all is the macros substitution. I cant see a work-a -round for that just yet, but maybe someone else will have an idea..
HTH //:^)