做了一个随机抽取人名的小程序. 从一个文本框输入姓名,然后添加到一个列表框中. 但是不能输入重复的姓名.要怎么实现呢? 我写的代码 Option Explicit Public j As Integer Public k As Integer Private Sub CmdAdd_Click() Dim t As Integer For t = 0 To j If List1.List(t) = Text1.Text Then MsgBox "不要输入重复滴名字,行不通滴!" End If Next List1.AddItem Text1.Text j = j + 1 End Sub
Private Sub cmdStart_Click() If Timer1.Enabled = False Then Timer1.Enabled = True k = 0 End If End Sub
Private Sub Timer1_Timer() Dim i As Integer i = Rnd * (9 * j / 10) List1.Selected(i) = True k = k + 1 If k = 400 Then Timer1.Enabled = False End If End Sub
每次会添加一个空值进去,真的不知道怎么实现.当出现重复姓名时,不做添加. 我是个初学者,代码写的也有点乱,希望高手指教.感激啊~
[此贴子已经被作者于2005-9-5 16:04:12编辑过]