|
-
Jan 24th, 2000, 01:10 AM
#1
You can store upto 2 Billion Characters in a String Variable, you will need to change the method of Loading the File into the Variable for Larger Files though, ie.
Code:
Private Sub Command1_Click()
Dim sData As String
Dim sChunk As String
Dim lChunk As Long
Dim lFileLen As Long
Dim iFile As Integer
iFile = FreeFile
'Open File For Binary Access
Open "C:\TestFile.csv" For Binary Access Read As iFile
lFileLen = LOF(iFile)
lChunk = 64000 'Load File in 64K Chunks
While Loc(iFile) < lFileLen
'Make sure the Buffer isn't Too Big
If Loc(iFile) + lChunk > lFileLen Then lChunk = lFileLen - Loc(iFile)
sChunk = Space(lChunk)
'Get the Next Chunk of Data
Get #iFile, , sChunk
'Append it to the Rest
sData = sData & sChunk
Wend
Close iFile
MsgBox "Done"
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
Jan 24th, 2000, 01:20 AM
#2
Hyperactive Member
Thanks Aaron, I'll try that.
-
Jan 24th, 2000, 12:08 PM
#3
Hyperactive Member
I'm trying to use:
intFreeFile = FreeFile
Open strFileName For Input As #intFreeFile
Line Input #intFreeFile, strLine
to read a csv file created by an online form. The problem is that the WEB db file only seperates the lines with chr(10). When reading the line, it needs chr(13) & chr(10) at the end of each line. This results in the entire file being written into strLine. I need a method that will either change the chr(10) into chr(13) & chr(10) before I start reading the lines into my variable OR a syntax change to make the LIE INPUT look for the chr(10). Any suggestions?
-
Jan 24th, 2000, 12:49 PM
#4
If you have VB6 then you can use Replace function to do the replace:
'Assuming that this is your text
Dim strText As String
strText = Replace(strText, Chr(10), vbCrLf)
strText now has the new text with Chr(10) + Chr(13) in it.
------------------
Serge
Programmer Analyst
[email protected]
[email protected]
ICQ#: 51055819
-
Jan 24th, 2000, 12:56 PM
#5
Hyperactive Member
I can replace the character once I get it in but I really need to do it Before I read from the file. I think what I would need to do is open the file and find and replace the chr(10). BUt I can't load it normally because it will load the entire CSV file into 1 string. This csv file is going to get very large and it will crash if it's all dumped into a variable. I need a way that I can open the file, repalce the chr(10) with the carriage return and line feed, save it and Then open it up normally. I have a feeling I'm not going to be able to do it in VB.
Is there a way in VB to open a file and globally replace a character Without putting it into a variable?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|