Solved

Semicolon Delimited Text

Posted on 2007-03-18
1
470 Views
Last Modified: 2009-12-16
hello,
I have this nice module that works on Tab Delimited Text
but Im having problems trying to convert it to Semicolon Delimited Text
can someone please help me?


Option Explicit

  Public FSO As FileSystemObject
  Public TS As TextStream
  Public lItem As ListItem
  Public J, I As Integer          'counters
  Public isEditSaved As Boolean   'edit boolean
  Public isChangeMade As Boolean  'saved boolean
 
  Dim tabLine() As String         'string to hold line of tab delimited text


Public Sub LoadFile(mPath As String, LVW As ListView)
  'clear any previous items in the listView
  LVW.ListItems.Clear
  Set FSO = New FileSystemObject
  'open the file for reading
  Set TS = FSO.OpenTextFile(mPath, ForReading, False)
  'split the line into a string array
  tabLine = Split(TS.ReadLine, vbTab)
  'cycle through the array and add the column headers
  For J = 0 To UBound(tabLine)
    LVW.ColumnHeaders.Add , , tabLine(J)
  Next J
  'cycle through the rest of the file to add the items
  While Not TS.AtEndOfStream
    tabLine = Split(TS.ReadLine, vbTab)
    Set lItem = LVW.ListItems.Add(, , tabLine(0))
    For J = 1 To UBound(tabLine)
      lItem.ListSubItems.Add , , tabLine(J)
    Next J
  Wend
  'close and clean up
  TS.Close
  Set TS = Nothing
  Set FSO = Nothing
End Sub

Public Sub SaveFile(mPath As String, LVW As ListView, useHeaders As Boolean)
  Set FSO = New FileSystemObject
  Set TS = FSO.OpenTextFile(mPath, ForWriting, True)
  'if saving headers, get them from the column header text
  'and write them to the file first
  If useHeaders Then
    For J = 1 To LVW.ColumnHeaders.Count
      TS.Write LVW.ColumnHeaders(J).Text & vbTab
    Next J
    TS.WriteLine
  End If
  'write all items to the file
  For J = 1 To LVW.ListItems.Count
    TS.Write LVW.ListItems(J).Text & vbTab
    For I = 1 To LVW.ListItems(J).ListSubItems.Count
      TS.Write LVW.ListItems(J).ListSubItems(I).Text & vbTab
    Next I
    TS.WriteLine
  Next J
  'close the file and clean up
  TS.Close
  Set TS = Nothing
  Set FSO = Nothing
End Sub
0
Comment
Question by:Sabrin
[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
1 Comment
 
LVL 35

Accepted Solution

by:
Raynard7 earned 500 total points
ID: 18745704
wouldnt you just substitute

vbTab with ";"

or make it a parameter that is passed to the function which defaults to vbTab
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

628 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