English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

我有一長串數字,想知道裡面分別有多少個數字,請問要怎麼用VB寫。假設這一串數字是1,1,1,2,2,2,3,3,3,4,4我想知道裡面有多少個1、有多少個2、有多少個3、有多少個4諸如此類的程式要怎麼寫呢?

2006-05-11 18:23:22 · 1 個解答 · 發問者 ? 5 in 電腦與網際網路 程式設計

這一串數據我已經用泡沫排序法從小排到大,還是說有人可以從原始比較亂的數據直接統計數字的數目?

2006-05-11 18:31:52 · update #1

1 個解答

'試試以下不用先排序的方式(01與1視為相異)Private Sub Command1_Click()Dim S$, W$, T&S = " 101,23,02,24,36,101, 101,28,27,01,26,25,01,02,02,02,101,18,17,26,25,101,23,02,24,36,101, 101,28,27,01,26,25,01,02,02,02,101,18,17,26,25,101,23,02,24,36,101, 101,28,27,01,26,25,01,02,02,02,101,18,17,26,25,101,23,02,24,36,101, 101,28,27,01,26,25,01,02,02,02,101,18,17,26,25,101,23,02,24,36,101, 101,28,27,01,26,25,01,02,02,02,101,18,17,26,25,101,23,02,24,36,101, 101,28,27,01,26,25,01,02,02,02,101,18,17,26,25,101,23,02,24,36,101, 101,28,27,01,26,25,01,02,02,02,101,18,17,26,25,101,23,02,24,36,101, 101,28,27,01,26,25,01,02,02,02,101,18,17,26,25"S = Replace(S, " ", "")S = "," & Replace(S, ",", ",,") & ","Do  W = Left(S, InStr(2, S, ","))  T = UBound(Split(S, W))  S = Replace(S, W, "")  Print Replace(W, ",", ""); " 共有 "; T; " 個"Loop Until Len(S) = 0End Sub

2006-05-15 21:51:36 · answer #1 · answered by W.J.S. 7 · 0 0

fedest.com, questions and answers