Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Semicolon Delimited Text

Posted on 2007-03-18
1
Medium Priority
?
477 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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

722 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