效率太低请大神修正,求助!
数据表上传到:http://www.说明历史号码与33选6的所有组合数逐一对比的方法,现在用VFP编了程序代码,但本人菜鸟级,于是执行效率太低,
请大神指点为谢。
以下是代码
程序代码:
IF EMPTY() MESSAGEBOX("请选择对比期数!",64,"消息窗口") retu ENDIF dimension iRed(33) j=1 FOR i=1 to 33 mycheck="thisform.check"+ALLTRIM(STR(i)) IF &mycheck..value=1 iRed(j)=IIF(i<10,"0","")+ALLTRIM(STR(i)) j=j+1 ENDIF NEXT IF j-1<6 MESSAGEBOX("至少选6位!",64,"消息窗口") RETURN ENDIF SELECT ssq DELETE all PACK thisform.image1.Visible= .T. thisform.image1.Width=0 thisform.label7.visible= .T. Tstar=DATETIME() i=1 FOR i1=1 to j-6 FOR i2=i1+1 to j-5 FOR i3=i2+1 to j-4 FOR i4=i3+1 to j-3 FOR i5=i4+1 to j-2 FOR i6=i5+1 to j-1 INSERT into ssq(id,hm,no1,no2,no3,no4,no5,no6) values(STR(i,10),ired(i1)+" "+ired(i2)+" "+ired(i3)+" "+ired(i4)+" "+ired(i5)+" "+ired(i6),ired(i1),ired(i2),ired(i3),ired(i4),ired(i5),ired(i6)) i=i+1 NEXT NEXT NEXT NEXT NEXT NEXT SELECT ssq REPLACE r1 with 0 ,r2 with 0,r3 with 0,r4 with 0,r5 with 0,r6 with 0 ,r7 with 0 all GO 1 SELECT RECNO() as hm_recn ,qh FROM hm WHERE ALLTRIM(qh)=ALLTRIM() INTO CURSOR te_a hmrecc=te_a.hm_recn SELE hm &&STORE RECCOUNT() to hmrecc LOCATE for qh= RECNO() to hmrecn jd=hmrecc-hmrecn jdt=0 do while not EOF() chm=hm.red1+" "+hm.red2+" "+hm.red3+" "+hm.red4+" "+hm.red5+" "+hm.red6 SELECT ssq do while not EOF() n=IIF(AT(No1,chm)>0,1,0)+IIF(AT(no2,chm)>0,1,0)+IIF(AT(no3,chm)>0,1,0)+IIF(AT(no4,chm)>0,1,0)+IIF(AT(no5,chm)>0,1,0)+IIF(AT(no6,chm)>0,1,0) DO CASE CASE n=0 REPLACE r1 with r1+1 CASE n=1 REPLACE r2 with r2+1 CASE n=2 REPLACE r3 with r3+1 CASE n=3 REPLACE r4 with r4+1 CASE n=4 REPLACE r5 with r5+1 CASE n=5 REPLACE r6 with r6+1 CASE n=6 REPLACE r7 with r7+1 ENDCASE SKIP ENDDO jdt=jdt+1 thisform.image1.Width=jdt/jd*700 SELECT ssq GO 1 SELECT hm SKIP IF RECNO()=hmrecc+1 EXIT do ENDIF ENDDO SELECT ssq REPLACE rtext with ALLTRIM(STR(r1))+" "+ALLTRIM(STR(r2))+" "+ALLTRIM(STR(r3))+" "+ALLTRIM(STR(r4))+" "+ALLTRIM(STR(r5))+" "+ALLTRIM(STR(r6))+" "+ALLTRIM(STR(r7)) all Tend=DATETIME() MESSAGEBOX("一共生成了"+ALLTRIM(STR(i-1))+"条记录,花费"+ALLTRIM(STR(tend-tstar))+"秒。",64,"消息窗口") thisform.label7.Visible= .F. thisform.image1.Visible= .F. IF MESSAGEBOX("您需要导出成TXT文件吗?",4+32,"消息窗口")=6 STORE ALLTRIM(STR(RECCOUNT())) TO ssqrecc GO 1 txtfile="ssq.txt" STRTOFILE("ID,HM,NO1,NO2,NO3,NO4,NO5,NO6,r1,r2,r3,r4,r5,r6,r7,RTEXT"+CHR(13)+CHR(10),txtfile,0) do while not EOF() STRTOFILE(ALLTRIM(id)+","+hm+","+No1+","+no2+","+no3+","+no4+","+no5+","+no6+","+ALLTRIM(STR(r1))+","+ALLTRIM(STR(r2))+","+ALLTRIM(STR(r3))+","+ALLTRIM(STR(r4))+", "+ALLTRIM(STR(r5))+", "+ALLTRIM(STR(r6))+","+ALLTRIM(STR(r7))+","+ALLTRIM(rtext)+CHR(13)+CHR(10),txtfile,1) WAIT WINDOW NOWAIT ALLTRIM(STR(RECNO()))+"/"+ssqrecc skip enddo MESSAGEBOX("已经生成TXT文件!",64,"消息窗口") ENDIF