Re: 如何讓listbox的值出現過不在出現呢???

看板Visual_Basic作者 (傑.J)時間17年前 (2008/04/05 07:23), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
※ 引述《parrotot (禎禎 新年快樂^^)》之銘言: : as title : 我一個數值範圍1到99重復跑..... : 按停止時顯示在listbox裡 : 每按一次就增加一個數字進去(1~99) : 如何讀出listbox里全部的值????? : 我打算重復出現讓他加一~~這種作法可以嗎??? 這樣子可以避免,一直取到重複值的問題。不知道還有沒有更好的方法? Public Class Form1 Dim tmp() As Byte Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load DefTmp() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim r As Random = New Random Dim a As Integer = r.Next(0, tmp.Length) ListBox1.Items.Add(tmp(a)) If tmp.Length = 1 Then DefTmp() Else Array.Copy(tmp, a + 1, tmp, a, tmp.Length - a - 1) ReDim Preserve tmp(tmp.Length - 2) End If End Sub Private Sub DefTmp() ReDim tmp(98) Dim i As Integer For i = 0 To 98 tmp(i) = i + 1 Next End Sub End Class -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.160.177.84
文章代碼(AID): #17zhXqRK (Visual_Basic)
文章代碼(AID): #17zhXqRK (Visual_Basic)