其实里面设计的是字符串是人名 这就用数字代替吧 比如从1-50人里选.第一次选到15,第二次算的时候就是1.2.3..13.14.16 就是不能包括15了,因为他第一次选了不能在有他了.我每点一次按钮就随机出来1个,不能为空.我一共点50下BUtton 这50个人都要出现不能有重复.因为一共就50人嘛.在下才疏学浅,忘各位高手帮忙 最好有代码

解决方案 »

  1.   

    StringList保存下50个人的名字使用随机数将这50个人的顺序打乱。然后通过产生随机数从50个人当中抽一个,抽出来之后,将其删除,或者移到最后。第二次随机数就只从49个人当中取...依此类推。
      

  2.   

    ...如何将他打乱啊 random(x)? 打乱他? 不知道你们做过没有 这种方法用1次行 第二次就不行了 不如你第一次选的是A,只要你把程序关闭.在打开头一次选的还是A
      

  3.   

    举例:
    窗体中加入一个Label控件,名为Label1,两个ListBox控件,分别为ListBox1,ListBox2,其中ListBox1用来记录名单,ListBox2用来取得中者名单.{--------生成人名列表用数字作人名为了测试----------}
    procedure TForm1.Button1Click(Sender: TObject);
    var
    i:integer;
    begin
     for i :=1  to 50 do begin
      ListBox1.Items.Add(inttostr(i));
     end;
    end;
    抽奖按钮:procedure TForm1.Button2Click(Sender: TObject);
    var
    i:integer;
    begin
      if ListBox1.Items.Count>0 then begin
      Randomize;
      i:=Random(ListBox1.Items.Count-1);
      ListBox2.Items.Add(ListBox1.Items.Strings[i]);
      ListBox1.Items.Delete(i);
      Label1.Caption:=inttostr(strtoint(Label1.Caption)+1);
      end;
    end;