Aenathras
06-13-2007, 12:54 AM
I don't know if anyone can advise me on this one.
I have a Public Function in a Module that I would like to call from several places from several forms but the file number I am printing to varies so I can create the files in a single data parse.
At the moment I have the following:
Public Function PrintToFile(FileNumber As Integer, strCol1 As Variant) As Integer
If FileNumber = 1 Then
Several 'Print #1' lines
Print #1, strCol
Several 'Print #1' lines
End If
If FileNumber = 2 Then
Several 'Print #1' lines
Print #1, strCol
Several 'Print #1' lines
End If
If FileNumber = 3 Then
Several 'Print #1' lines
Print #1, strCol
Several 'Print #1' lines
End If
PrintToFile = 1
End Function
While what I would like - to simplify my code - is to have something like the pseudo-code:
Public Function PrintToFile(FileNumber As Integer, strCol1 As Variant) As Integer
Several 'Print #1' lines
Print FileNumber, strCol
Several 'Print #1' lines
PrintToFile = 1
End Function
However I haven't been able to find a way to parameterise the Print command so that number of the file #1, #2, #3 etc. get passed into the function.
Has anyone come accross this one before?
Aenathras
I have a Public Function in a Module that I would like to call from several places from several forms but the file number I am printing to varies so I can create the files in a single data parse.
At the moment I have the following:
Public Function PrintToFile(FileNumber As Integer, strCol1 As Variant) As Integer
If FileNumber = 1 Then
Several 'Print #1' lines
Print #1, strCol
Several 'Print #1' lines
End If
If FileNumber = 2 Then
Several 'Print #1' lines
Print #1, strCol
Several 'Print #1' lines
End If
If FileNumber = 3 Then
Several 'Print #1' lines
Print #1, strCol
Several 'Print #1' lines
End If
PrintToFile = 1
End Function
While what I would like - to simplify my code - is to have something like the pseudo-code:
Public Function PrintToFile(FileNumber As Integer, strCol1 As Variant) As Integer
Several 'Print #1' lines
Print FileNumber, strCol
Several 'Print #1' lines
PrintToFile = 1
End Function
However I haven't been able to find a way to parameterise the Print command so that number of the file #1, #2, #3 etc. get passed into the function.
Has anyone come accross this one before?
Aenathras