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

Heenan, Lambert Lambert.Heenan at AIG.com
Fri Jul 8 15:50:35 CDT 2005


This code will not work because you do not assign the value of strFileText
to the name of the function (which is how you make a function return
something). Also you did not declare the function return type, so it will
default to a Variant. Not that that would prevent the function for working.

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
rusty.hammond at cpiqpc.com
Sent: Friday, July 08, 2005 4:42 PM
To: accessd at databaseadvisors.com
Subject: RE: [AccessD] Read the contents of a file into a memvar


Arthur,
If the file you're reading is just a simple text file, then the following
should work:

Function ImportTextFileIntoVar()

    Dim strTextLine
    Dim strFileText As String
    Dim strFileName As String
    
    strFileName = "i:\test.txt"
    
    Open strFileName For Input As #1
    
    Do While Not EOF(1)
        Line Input #1, strTextLine
        strFileText = strFileText & vbCrLf & strTextLine
    Loop
        
    Close 1

End Function

Rusty

-----Original Message-----
From: Arthur Fuller [mailto:artful at rogers.com]
Sent: Friday, July 08, 2005 2:52 PM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Read the contents of a file into a memvar


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.

TIA,
Arthur

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

**********************************************************************
WARNING: All e-mail sent to and from this address will be received, scanned
or otherwise recorded by the CPI Qualified Plan Consultants, Inc. corporate
e-mail system and is subject to archival, monitoring or review 
by, and/or disclosure to, someone other than the recipient.
**********************************************************************
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list