Solved

Semicolon Delimited Text

Posted on 2007-03-18
1
466 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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

679 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