Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


LoadCSV from a variable


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-29-2008, 07:18 PM
Newbie
 
Join Date: Jan 2008
Posts: 6
Default LoadCSV from a variable

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, ",", false, true)
Reply With Quote
  #2 (permalink)  
Old 01-29-2008, 07:37 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,343
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

What is the tipe of the "Response" control?
Does the getresponse statements retrieve any result?
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #3 (permalink)  
Old 01-29-2008, 07:40 PM
Newbie
 
Join Date: Jan 2008
Posts: 6
Default

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!
Reply With Quote
  #4 (permalink)  
Old 01-29-2008, 07:46 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,343
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

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

Quote:
Properties and Methods:
Add
BringToFront
Clear
Color
Count
Dispose
Enabled
Focus
FontColor
FontSize
Height
Insert
Item
Left
Name
Refresh
Remove
RemoveAt
SelectedIndex
Top
Visible
Width
Events:
GotFocus
SelectionChanged
LostFocus
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...
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #5 (permalink)  
Old 01-29-2008, 08:27 PM
Newbie
 
Join Date: Jan 2008
Posts: 6
Default

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
Reply With Quote
  #6 (permalink)  
Old 01-29-2008, 08:29 PM
Newbie
 
Join Date: Jan 2008
Posts: 6
Default

Or... is there an easier way to loop through CSV data and add each row to the table (or a listbox)?
Reply With Quote
  #7 (permalink)  
Old 01-29-2008, 09:25 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,343
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

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

Quote:
StrSplit Previous Top Next

--------------------------------------------------------------------------------
Splits a string and returns an array of strings.
Syntax: SrtSplit (RawString, Separators)
RawString - The string that will be split.
Separators - Zero or more characters that act as the separators.
If the Separators string is an empty string then all white characters will be used as the separators.
Example:
Sub Globals
dim words(0) as string
End Sub
Sub App_Start
sentence = "$GPGGA,161229.487,3723.2475,N,12158.3416,W,1,07,1 .0,9.0,M,,,,0000*18"
words() = StrSplit(sentence, ",")
for i = 0 to ArrayLen(words())-1
msgbox(words(i))
next
End Sub
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #8 (permalink)  
Old 01-30-2008, 02:29 AM
alfcen's Avatar
Basic4ppc Veteran
 
Join Date: Apr 2007
Location: Okinawa, Ryukyu
Posts: 424
Awards Showcase
Beta Tester 
Total Awards: 1
Default

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", ",", false, true)
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.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Possibility of transfering variable value from one EXE to other EXE. mozaharul Questions & Help Needed 3 10-16-2008 03:38 PM
Table1.LoadCSV s_ostap Russian Forum 3 07-03-2008 09:30 AM
Dim variable c% as Double colin9876 Basic4ppc Wishlist 8 05-28-2008 02:26 PM
Probleme mit LoadCSV und ANSI - UTF-8 Holger.D German Forum 2 05-13-2008 08:23 PM
loadcsv and accent claveriel Questions & Help Needed 10 11-15-2007 05:16 PM


All times are GMT. The time now is 02:29 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0