uSelOne.pas
上传用户:lzd18710
上传日期:2009-11-26
资源大小:3595k
文件大小:1k
源码类别:

通讯编程

开发平台:

Visual Basic

  1. unit uSelOne;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, StdCtrls;
  6. type
  7.   TfrmSelOne = class(TForm)
  8.     ListBox1: TListBox;
  9.     Button1: TButton;
  10.     Button2: TButton;
  11.   private
  12.     { Private declarations }
  13.   public
  14.     { Public declarations }
  15.   end;
  16. function SelectItem(Items: tstrings; var Selected: integer): string;
  17. implementation
  18. {$R *.dfm}
  19. function SelectItem(Items: tstrings; var Selected: integer): string;
  20. var
  21.   frmSelOne: TfrmSelOne;
  22. begin
  23.   frmSelOne:= TfrmSelOne.Create(application);
  24.   try
  25.     frmSelOne.ListBox1.Items.Assign(Items);
  26.     if (Selected>=0) and (Selected<frmSelOne.ListBox1.Items.Count) then
  27.       frmSelOne.ListBox1.ItemIndex:=Selected;
  28.     if frmSelOne.ShowModal=mrok then
  29.     begin
  30.       selected := frmSelOne.ListBox1.ItemIndex;
  31.       if selected>=0 then
  32.         result := frmSelOne.ListBox1.Items[selected];
  33.     end;
  34.   finally
  35.     frmSelOne.Free;
  36.   end;
  37. end;
  38. end.