gettingstarted
[Top] [All Lists]

Re: Reading in text from a file into a ListBox with 2 columns

To: Getting Started <gettingstarted at lists dot realsoftware dot com>
Subject: Re: Reading in text from a file into a ListBox with 2 columns
From: Paul Young <youngpr at myactv dot net>
Date: Sun, 30 Jan 2005 08:23:04 -0500
Delivered-to: gettingstarted at lists dot realsoftware dot com
References: <BE21BF8C dot 1A10C%pheycock at bellsouth dot net>
Phil,

I'll be working on this today.  Really appreciate the suggestions.

Paul


On Jan 29, 2005, at 10:32 PM, Phil Heycock wrote:

Hi, Paul,

Taking this a step further, consider making the 'write-to-file' a part of
the custom ListBox class functionality, as well. Add another method:

Sub writeToTextFile(t As TextOutputStream)
    Dim row As Integer
    // Write the first row to file
    t.WriteLine concatenateRow(row) // row is zero (0) here
    // Write the remaining rows, if any... delimited
    For row = 1 To ListCount - 1
        t.WriteLine EndOfLine + concatenateRow(row)
    next
End Sub

Your PushButton.Action event would contain this code, calling a method
('saveListBox') in the Window:

Sub Action()
    If ListBox1.ListCount > 0 Then
        saveListBox
    Else
        Beep
        MsgBox "The ListBox is empty. Nothing to save."
    End If
End Sub

Sub saveListBox ()

    dim f as FolderItem = PreferencesFolder.Child("filename.plist")
    dim t as TextOutputStream = f.CreateTextFile

    If t <> nil Then
        ListBox1.writeToTextFile t
        t.close
    Else
        Beep
        MsgBox "File not opened. Nothing saved."
    End If

End Sub


Function contatenateRow(row As Integer) As String
    Dim col As Integer
    Dim rowTxt As String = Cell(row, col) // col is zero (0) here
    For col = 1 To ColumnCount - 1
        rowTxt = rowTxt + HT + Cell(row, col)
    Next
    Return rowTxt
End Function

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>