รหัสสำหรับการบันทึกแบบสุ่มในชุดบันทึก
-
'Movingtorandomrecord-stevenjones'extension
ifnot (บันทึกชื่อชื่อ bofand record set name.eof) จากนั้น
'RESETTHECURSORTOTHEBEGINNING
if (recordset name.cursortype> 0) จากนั้น
recordset name.movefirst
อื่น
recordset name.requery
endif
recordset name_totalrn = -1
Recordset name_totalrn = recordset name.recordcount'onyworksonsomerecordsets, butmuchfaster
if (บันทึก set name_totalrn = -1) แล้วจะไม่ทำงาน, Westillhavetocounttherecords
'CountTheToTalRecordsByiteratingthroughTherecordset
recordset name_totalrn = 0
ในขณะที่ (ไม่ใช่บันทึก set name.eof)
recordset name_totalrn = recordset name_totalrn+1
recordset name.movenext
ใช้
'RESETTHECURSORTOTHEBEGINNING
if (recordset name.cursortype> 0) จากนั้น
recordset name.movefirst
อื่น
recordset name.requery
endif
endif
'Nowdofinaladjustments และ MovetotherandamRecord
recordset name_totalrn = recordset name_totalrn-1
ถ้าบันทึก set name_totalrn> 0 แล้ว
สุ่ม
recordset name.moveint ((recordset name_totalrn+1)*rnd)
endif
endif
'Alldone; YouShouldalwayscheckForanEmpyRecordsetBeforedisplayingData
-