標題:

一題VB的程式設計問題

發問:

有一組數字 {123,767,903,872,454,305,12} , 計算0到9數字的個數 請問這程式碼要怎麼寫 ?

最佳解答:

Private Sub Command1_Click()?? NumStr = "123,767,903,872,454,305,12"?? For i = 0 To 9???????? Print i; " 的個數 = "; UBound(Split(NumStr, i))?? NextEnd Sub

其他解答:

 

此文章來自奇摩知識+如有不便請留言告知

不好意思,能解說一下各行程式碼嗎,我剛開始學,不是很懂,謝謝|||||Private Sub Form_Activate()??? a = Array(123, 767, 903, 872, 454, 305, 12)??? mystr = ""??? For i = 0 To UBound(a)??????? mystr = mystr + Format(a(i), "#")??? Next??? Dim b(9) As Integer??? For i = 0 To 9??????? b(i) = Len(mystr) - Len(Replace(mystr, Format(i, "#"), ""))??????? Print i; " 有 "; b(i); " 個"??? NextEnd Sub 2006-04-12 07:41:48 補充: 抱歉:mystr = mystr + Format(a(i), "#")應改成mystr = mystr + Format(a(i), "0")b(i) = Len(mystr) - Len(Replace(mystr, Format(i, "#"), ""))應改成b(i) = Len(mystr) - Len(Replace(mystr, Format(i, "0"), ""))6524A8F25B63629D
arrow
arrow

    jpjzhf9 發表在 痞客邦 留言(0) 人氣()