我做了个抽奖的程序  随机抽出1条记录我会 我想随机抽出20条记录 该怎么写啊!!!!

解决方案 »

  1.   

    Private Sub Command1_Click()
    Dim MyTimer
    Dim Numberholder(6) As Integer
    For x = 0 To 19
        Randomize'初始化种子
        TheValue = Int((20 * Rnd) + 1)
        Numberholder(x) = TheValue
        Picture1(x).Picture = LoadResPicture(Numberholder(x), 0)
    Next x
    End Sub
      

  2.   

    有时间,帮你写一个,这是pb的,不好意思
    for j=1 to rs//rs是总的人数,比如100人
    flag=false
    int rl,k
    rl=dw_4.retrieve(zy)//数据窗的行数,vb中可以加到表格中
    Randomize(0)
    bh=rand(rl)//从20个中选择
    int dqbh
    pwbh=dw_4.getitemstring(bh,"bh")//然后得到选择的编号的信息
    select count(*) into :ll from ztb_fs where zbbh=:sle_bjbh.text and pwbh=:pwbh;
    if ll=0 then
    insert into ztb_fs(zbbh,pwbh) values(:sle_bjbh.text,:pwbh);
    else
    do 
    Randomize(0)
    bh=rand(rl)
    pwbh=dw_4.getitemstring(bh,"bh")
    select count(*) into :ll from ztb_fs where zbbh=:sle_bjbh.text and pwbh=:pwbh;
    if ll=0 then
    insert into ztb_fs(zbbh,pwbh) values(:sle_bjbh.text,:pwbh);
    flag=true
    end if
    loop until flag=true
    end if
    next
    next
      

  3.   

    Private Declare Function SendMessagebyString Lib _
    "user32" Alias "SendMessageA" (ByVal hWND As Long, _
    ByVal wMsg As Long, ByVal wParam As Long, _
    ByVal lParam As String) As LongPrivate Const LB_FINDSTRINGEXACT = &H1A2Private Sub Command1_Click()
    dim TheValue as stringRandomize'初始化种子
    List1.ClearDo until list1.listcount = 20
        TheValue = CStr( Rnd * RecordCount) 'RecordCount=总记录数
        If SendMessagebyString(List1.hWnd, LB_FINDSTRINGEXACT, -1, TheValue)= -1 then
            List1.AddItem TheValue
        End If
    LoopEnd Sub