my code as follow
Public FileName As String Private Sub CommandButton1_Click() Dim c As String Dim FileName As String Dim word As String 'Dim c As String Dim i As Integer Dim FileNo As String Dim w() As Characters i = 1 c = FreeFile Open_File Open FileName For Input As #1 Do While Not EOFİ word = "" c = Input(1, #1) If c <> Empty Then word = word + c ElseIf Len(word) <> 0 Then w(i) = word i = i + 1 Else word = Empty End If Loop MsgBox word Close #1 End Sub Public Sub Open_File() FileName = "c:\in.txt" End Sub
thanks in advance
One file of unknown length has in each line some words. The number
of words may be different in each line and blank (empty) lines are
allowed. Words may be separated, preceded, and followed, by any
number of spaces. The input file contains spaces and only
alphabetic and numeric characters. It is known in advance that the
number of different words is 100.
Write a VBA program to count the number of each word, it saves in
an output file the result of this count, sorted by the number of
occurrences in decreasing order. When the number of occurrences
is the same for some words, the order of those words is not important.
Optional: if the number of occurrences of some words is the same,
sort them in alphabetical order.