有一組數字 {123,767,903,872,454,305,12} , 計算0到9數字的個數
請問這程式碼要怎麼寫 ?
PS: 需用 Visual Basic . Net
抱歉喔,我不是相關科系的,不知道有簡單一點的嗎?我看第一行是
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As_ System.EventArgs) Handles Button1.Click
之前的問題被刪除了,程式碼還沒記起來
2006-05-01 13:26:53 · 1 個解答 · 發問者 ? 2 in 電腦與網際網路 ➔ 程式設計
不是我惡意移除,是時間到了,我忘了選出最佳解答,就被移除了,能麻煩你再告訴我一下程式碼嗎,抱歉~~
2006-05-01 17:24:33 · update #1
問題被刪除??
不是你惡意移除嗎?
給點事小,
惡意移除事大。
2006-05-01 21:29:09 補充:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim a(10) As Integer
Dim i As Integer
Dim s As String
s = "{123,767,903,872,454,305,12}"
For i = 1 To Len(s)
Select Case Mid(s, i, 1)
Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
a(Val(Mid(s, i, 1) + 1)) += 1
End Select
Next
MsgBox(s & "含有" & Chr(13) & " 0: " & a(1) & " 個" _
& Chr(13) & " 1: " & a(2) & " 個" _
& Chr(13) & " 2: " & a(3) & " 個" _
& Chr(13) & " 3: " & a(4) & " 個" _
& Chr(13) & " 4: " & a(5) & " 個" _
& Chr(13) & " 5: " & a(6) & " 個" _
& Chr(13) & " 6: " & a(7) & " 個" _
& Chr(13) & " 7: " & a(8) & " 個" _
& Chr(13) & " 8: " & a(9) & " 個" _
& Chr(13) & " 9: " & a(10) & " 個" _
, , "訊息視窗")
End Sub
2006-05-01 17:29:09 · answer #1 · answered by 上官 5 · 0⤊ 0⤋