[AccessD] Read the contents of a file into a memvar

Stuart McLachlan stuart at lexacorp.com.pg
Fri Jul 8 18:46:07 CDT 2005


On 8 Jul 2005 at 15:52, Arthur Fuller wrote:

> I need to do what the subject says. The file might possibly be 1000 chars
> but more likely fewer. What I would ideally like to do is this:
> 
> Dim myText as string
> Dim strSourceFile as string
> strSourceFile = xxxx
> myText = ReadFile( strSourceFile )
> 
> And then, once I am done, post said text to a Word bookmark... but that part
> is easy.
> 

Function Readfile(SourceFile As String) As String
Dim strBuffer As String

'Make the Buffer the full size of the file
strBuffer = Space$(FileLen(SourceFile))

'Allow for concurrent multi user access
Open SourceFile For Binary Access Read Shared As #1

Get #1, , strBuffer
Close #1
Readfile = strBuffer
End Function

-- 
Stuart





More information about the AccessD mailing list