Re: [.NET] 產生亂數 ... 我這樣寫哪裡有問題

看板Visual_Basic作者 (矇面加菲獅)時間18年前 (2006/12/27 12:46), 編輯推噓1(101)
留言2則, 1人參與, 最新討論串2/5 (看更多)
※ 引述《Bonder (Yes)》之銘言: : 各位大大...小弟初學VB.net : 想要產生6個亂數在1-49之間 : 很直觀就這樣寫 Dim i As Int16, j As Int16, Exists As Boolean Dim r(5) As Integer Randomize() For i = 0 To 5 Do r(i) = Int(Rnd() * (49 - 1) + 1) '最大值減最小值加一才對@@ Exists = False '檢查是否重複 For j = 0 To i - 1 If r(i) = r(j) Then Exists = True : Exit For Next If Not Exists Then Exit Do Loop Next For i = 0 To 5 Controls("Label" & (i + 1)).Text = r(i) Next -- ▃▅▇▆▄ ▆▂▃ ` 逝去感如何能留住,半點遺留殊不易,██▅▇▄▃ ▇▃▂" . █████████▃i ▁▄▇ 更多悽悽慘慘的遭遇………██▆▃ █▅▆▃ˍ▄* ▂█▄▇▅▂. 我不知道,王~八~蛋~~! ▂▆███ █▄▃ 。fumizuki。Check。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 60.248.175.60

01/07 16:06, , 1F
還是會出現:從字串 "Label1" 轉換為型別 'Integer' 是無效的
01/07 16:06, 1F

01/07 16:07, , 2F
錯誤發生在controls那邊 這是什麼問題?
01/07 16:07, 2F
文章代碼(AID): #15aVg9bw (Visual_Basic)
文章代碼(AID): #15aVg9bw (Visual_Basic)