Solved

Semicolon Delimited Text

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

747 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now