|
-
April 20th, 2001, 10:50 AM
#1
Replace string in a file
Hi,
I have a very large file where i want to delete all quotation marks before and after a comma,
What is the fast way to do that?
Thanks,
Sue
-
April 20th, 2001, 11:05 AM
#2
Re: Replace string in a file
Dim strFileName as string
Dim strHuge as string
Dim ln as Long
Dim strFileContent() as string
Dim iFile as Integer
iFile = FreeFile
strFileName = "path\to\your\file.ext"
Open strFileName for input as #iFile
ln = FileLen(strFileName)
strHuge = Space(ln)
strHuge = input(ln, iFile)
Close #iFile
strHuge = Replace(strHuge, "," & chr(34), "")
strHuge = Replace(strHuge, chr(34) & ",", "")
iFile = FreeFile
Open strFileName for output as #iFile
print #iFile, strHuge
Close #iFile
--Some code thanks to sharathms--
-K
-
April 20th, 2001, 11:16 AM
#3
Re: Replace string in a file
i am using vb5, is Replace function available in vb5?
-
April 20th, 2001, 03:14 PM
#4
Re: Replace string in a file
Replace is not available in VB5
Iouri Boutchkine
[email protected]
-
April 20th, 2001, 03:27 PM
#5
Re: Replace string in a file
Well since replace isn't in VB5 then I will give you similar code using the InStr function. I hope that function is in VB5.
Dim strFileName as string
Dim strHuge as string
Dim ln as Long
Dim strFileContent() as string
Dim iFile as Integer
Dim lPos as Long
iFile = FreeFile
strFileName = "path\to\your\file.ext"
Open strFileName for input as #iFile
ln = FileLen(strFileName)
strHuge = Space(ln)
strHuge = input(ln, iFile)
Close #iFile
lPos = InStr(strHuge, "," & chr(34))
while lPos <> 0
strHuge = Left(strHuge, lPos - 1) & mid(strHuge, lPos + 2)
lPos = InStr(strHuge, "," & chr(34))
wend
lPos = InStr(strHuge, chr(34) & ",")
while lPos <> 0
strHuge = Left(strHuge, lPos - 1) & mid(strHuge, lPos + 2)
lPos = InStr(strHuge, chr(34) & ",")
wend
iFile = FreeFile
Open strFileName for output as #iFile
print #iFile, strHugeClose #iFile
--Some code thanks to sharathms--
-K
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
|