LoadCSV from a variable

Discussion in 'Questions (Windows Mobile)' started by nsidney, Jan 29, 2008.

  1. nsidney

    nsidney Member Licensed User

    I would like to load CSV data from a webresponse variable into a ListBox, but I get the error "Object reference not set to an instance of the object." Is there a way around this?

    Thanks

    Code:
    Response.Value = Request.GetResponse
    result = Response.GetString
    Response.Close
    Eventlist.loadcsv(result, 
    ","falsetrue)
     
  2. Cableguy

    Cableguy Expert Licensed User

    What is the tipe of the "Response" control?
    Does the getresponse statements retrieve any result?
     
  3. nsidney

    nsidney Member Licensed User

    the "result" is the result of a WebReponse function and data is actually returned successfully (I verified that with a msgBox that displays the value of "result").

    thanks!
     
  4. Cableguy

    Cableguy Expert Licensed User

    These are the properties and methods supported by a listbox...

    The is no loadcsv method in a listbox, but there is one tablecontrol...
    Code:
    Properties and Methods:
                 AddCol
                 AddRow
                 BringToFront
                 CaseSensitive
                 Cell
                 Clear
                 ColCount
                 ColName
                 ColNumber
                 Color
                 ColWidth
                 Dispose
                 Enabled
                 Filter
                 Focus
                 FontColor
                 FontSize
                 HeaderColor
                 HeaderFontColor
                 HeaderVisible
                 Height
                 Left
                 LinesColor
                 LoadCSV
                 LoadXML
                 Name
                 Refresh
                 RemoveCol
                 RemoveRow
                 RowCount
                 SaveCSV
                 SaveXML
                 SelectCell
                 SelectedCol
                 SelectedRow
                 TableSort
                 Top
                 Visible
                 Width
    Events:
                 SelectionChanged
    Wich you can read and populate the listbox...
     
  5. nsidney

    nsidney Member Licensed User

    Oops... didn't notice the difference there ;).

    Ok so when I changed it into a Table control, it thinks "result" is the name of the file. How can I take "response" and feed that into a file and then send that file name to this LoadCSV function?

    Thanks
     
  6. nsidney

    nsidney Member Licensed User

    Or... is there an easier way to loop through CSV data and add each row to the table (or a listbox)?
     
  7. Cableguy

    Cableguy Expert Licensed User

    Were does the data came from? a file or from a web site?
    If all the data cames in a simple string with a know separator you can use StrSplit

     
  8. alfcen

    alfcen Well-Known Member Licensed User

    Hi nsidney,

    If the expected data amount in 'result' is small then please try this way:

    Code:
    Response.Value = Request.GetResponse
    result = Response.GetString
    Response.Close

    FileOpen(c1,AppPath & 
    "\interim.csv",cWrite)
    FileWrite(c1,result)
    FileClose(c1)

    Table1.LoadCSV(AppPath & 
    "\interim.csv"","falsetrue)
    You can then populate a listbox or a combobox from the table with the
    added advantage of having a backup file of the downloaded data.
     
Loading...