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

拜託,滿急的,因為我想要讓學生玩"尋字遊戲",所以需要一個程式可以把我丟進去的文章,自動抓出10x20陣列(約一張A4大小)的亂數中文(能直接產生在Excel最好了!),希望有高手能出面相助,感激不盡!奉上銀兩二十點!

2005-12-12 08:51:22 · 1 個解答 · 發問者 Anonymous in 電腦與網際網路 程式設計

1 個解答

Private Sub Command1_Click()
Dim A() As Byte, Dr As String, S As String, S1 As String, S2 As String, X As Long
Dr = "C:\TEST.txt" '你的文字檔
ReDim A(FileLen(Dr) - 1)
Open Dr For Binary As #1
Get #1, , A
Close #1
S = StrConv(A, vbUnicode)
Randomize
Do
X = Int((Len(S) * Rnd) + 1)
S2 = Mid(S, X, 1)
If AscB(StrConv(S2, vbFromUnicode)) > 128 Then
If InStr(S1, S2) = 0 Then S1 = S1 & S2
End If
Loop Until Len(S1) = 200
Dim Ex As Object
Set Ex = CreateObject("Excel.Sheet")
X = 1
For I = 1 To 20
For J = 1 To 10
Ex.Application.Cells(I, J).Value = Mid(S1, X, 1)
X = X + 1
Next
Next
X = 2: S = "C:\TEST001.xls"
Do Until Dir(S) = ""
S = "C:\TEST" & Format(X, "000") & ".xls"
X = X + 1
Loop
Ex.SaveAs S
Ex.Application.Quit
Set Ex = Nothing
MsgBox "已產生 : " & S & " 檔案!!"
End Sub

2005-12-12 11:53:53 · answer #1 · answered by W.J.S. 7 · 0 0

fedest.com, questions and answers