Complie Problem VB6

ADO-Nick

New member
Local time
Today, 13:43
Joined
Oct 2, 2003
Messages
8
I just created a new subroutine in VB6, as below. I now get a compile time error message:

"Statement invalid outside Type Block"

Can anyone enlighten me as to why?

Private Sub ImportData()

code etc.

End Sub

Thanks for any help,
ADO-Nick
 
code etc. does not appear to be a valid VB function. ;)

Post your code and bold what is hi-lited when you try to compile it.

Listing the exact error number and error message will also help us, help you.
 
Thanks, ghudsen

There is no error number. Exact message is as previous posting. Compile stops on highlighted line.

Private Sub ImportData()
'update DB with new input data

Dim arNewFiles() As NewFiles 'array of datasets to read
Dim intNewFiles As Integer 'number of new datasets to read
Dim strFileName As String 'name of dataset to process
Dim strTableName As String 'name of temp MS Access storage table
Dim objNewData() As DataIn 'array of new data from input file
Dim artmp(4) As String
Dim i As Integer

'read directory & establish filelist
ReadDirectory(arNewFiles) As Integer
intNewFiles = ReadDirectory(arNewFiles())
tsLog.writeline "Number of new datasets is " & intNewFiles + 1

'loop thro filelist & extract data
For i = 0 To intNewFiles
'assemble FULL filepath+name
artmp(0) = arDir(1)
artmp(1) = "\"
artmp(2) = arNewFiles(i).name
artmp(3) = "."
artmp(4) = arNewFiles(i).type
strFileName = Join(artmp, "")
tsLog.writeline "Filename being processed is... " & strFileName

'Read dataset
ReadDataset strFileName, objNewData

'create temp table
strTableName = arNewFiles(j).type & arNewFiles(j).date
strTableName = Replace(strTableName, "/", "", , , vbTextCompare)
If DEBUGGING Then tsLog.writeline "Table Name... " & strTableName
CreateTable strTableName

'store data into temp table
StoreData strTableName, objNewData

'clean up
ReDim objNewData(0)

Next i

End Sub
 
I believe your problem code is:

Code:
ReadDirectory(arNewFiles) As Integer

as with that code you are defining a Type instead of creating a variable by using the DIM statement before it.
 
Conclusion

Thanks boblarson

Can't see the wood for the trees!!:D

ADO-Nick
 

Users who are viewing this thread

Back
Top Bottom