? INT(RAND(HOUR(DATE())*MINUTE(DATE())*SEC(DATE()))*1000000)
用時分秒來相乘就一天只有一次重複的概率
[ 本帖最后由 karycheung 于 2015-1-10 15:29 编辑 ]
用時分秒來相乘就一天只有一次重複的概率
[ 本帖最后由 karycheung 于 2015-1-10 15:29 编辑 ]
? _RandNum() FUNCTION _RandNum() LOCAL dtName, nRecno, szNum dtName = "dt.dbf" IF !FILE(dtName) CREATE TABLE (dtName) (Num C(6)) FOR i = 0 TO 999999 APPEND BLANK ENDFOR REPLACE ALL Num WITH PADL(RECNO()-1, 6, "0") USE ENDIF CREATE CURSOR dt (Num C(6)) APPEND FROM (dtName) IF !EOF() nRecno = INT((RECCOUNT() - 1) * RAND() + 1) GO nRecno szNum = dt.Num COPY TO (dtName) FOR RECNO() != nRecno ELSE szNum = "" ENDIF RETURN szNum ENDFUNC