The GW-Scripting list is a discussion list for information regarding the development and use of Window-Eyes scripts. Any subscriber of the GW-Scripting list has the ability to post on-topic messages.

From:

 David

Subject:

 Please help - why does this not work?

Date:

 Wed, Feb 3, 2010 8:03:52 pm
I have the following script. Running it, the last line results in a 'type mismatch' error. What am I missing?

'Objects
Dim FS: Set FS = CreateObject( "Scripting.FileSystemObject" )

'Variables
Dim Filename, Line
Dim Lines()
Dim Number
Dim Textfile


'Functions
Function SortArray( OldArray() ) 'Returns a sorted copy of the incoming Array
Dim EntryNumber, ZZZ
Dim TempEntry
'---Function Code Starts---
EntryNumber = 0
Do
EntryNumber = EntryNumber + 1
TempEntry = oldArray( EntryNumber -1 )
If OldArray( EntryNumber ) = UBOUND( OldArray )
SortArray = OldArray
End Function 'SortArray


'---Main Code---
Filename = InputBox( "Name of file to be sorted: ", "Text File Sorting" )
Set Textfile = FS.OpenTextFile( Filename, 1, False )

Number = -1
Do Until Textfile.AtEndOfStream
Number = Number + 1
Redim Preserve Lines( Number + 1 )
Lines( Number ) = Textfile.ReadLine
Loop
Textfile.Close
Set Textfile = Nothing
Lines = SortArray( Lines )


Thanks a whole lot!

--
I am using the free version of SPAMfighter.
We are a community of 6 million users fighting spam.
SPAMfighter has removed 611 of my spam emails to date.
Get the free SPAMfighter here: http://www.spamfighter.com/len

The Professional version does not have this message