Solved

VBA remove commas

Posted on 2012-03-14
5
479 Views
Last Modified: 2012-03-30
i am trying to find some code that will remove commas from a csv file.
i am trying to import a csv file using ssis but the commas screw my fields up.
0
Comment
Question by:aneilg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 48

Accepted Solution

by:
Martin Liss earned 155 total points
ID: 37720628
Dim strBuffer As String
' Define an Integer to hold the file number
Dim FF As Integer

' Find a file number that's not in use
FF = FreeFile

Open "c:\temp\Test.txt" For Input As #FF

' The format of 'Input' is Input(how-many-bytes, file-number) and
' LOF is Length Of File so how-many-bytes is set at length of the file
strBuffer = Input(LOF(FF), FF)
strBuffer = Replace(strBuffer, "," , "|") ' replace the commas with |. You could also use " " or ""
Close #FF
Kill "c:\temp\Test.txt"
Open "c:\temp\Test.txt" For Output As #FF
Print #FF, strBuffer
Close #FF
0
 

Author Comment

by:aneilg
ID: 37720685
thank i'll give it a go.
0
 
LVL 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 155 total points
ID: 37722400
Normally the comma would be your delimiter in a CSV file.

Is the problem that some of your actual values themselves have commas?
0
 

Author Closing Comment

by:aneilg
ID: 37786889
partly answered
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 37787290
Instead of a "C" grade you could have asked for more help with whatever problem(s) remained.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question