Sort Program-How to?
Posted on 2006-05-30
I have more than 3 words I am trying to sort. (I am self learning programming and they say the sort is the best place to start)
My code is below. I am able to declare my variables, open a text file with the above words in it and write those words to another file. My problem lies in sorting them. The looping and if statement are giving me problems. Help! When I run the .vbs program I get an error that says line 19 char 5, input past end of file. I tryed doing something with (x + 1) but I am failing because of my lack of knowledge. Thankyou for helping!!
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("D:\Temp\sort\test.txt", ForReading)
do until objFile.AtEndOfStream
Word1 = objFile.Readline
word2 = objFile.Readline
If word1 > word2 then
word2 = replace(word2, "word1", "word2")
Set objFile = objFSO.OpenTextFile("D:\Temp\sort\test2.txt", ForWriting)