|
-
May 16th, 2008, 01:32 PM
#1
Thread Starter
Lively Member
Listbox Adding
ok i want to show the contents of a txt file located online. iv used inet to grab the content of the text file:
but in this txt file it has carridge return (char(10)) and i want it to show in the listbox as new items. this is wat iv got so far in the module:
Module Code:
Public Sub ServerDataParse(SiteFile As String)
For i = 0 To Form1.List2.ListIndex
' this is where im gettin lost...
Form1.List2.AddItem SiteFile
' Form1.Text1 = SiteFile
End Sub
Can anyone help me out?
Did a reply help answer your questions? Please RATE good posts!
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
New Laptop System: Intel Dual-Core T2060 2.0GHz • 533MHz FSB • 2MB Cache • 1024MB RAM • 120GB Hard Drive • Dual Layer DVD ReWriter MultiDrive • 15.4" Widescreen Display • Microsoft Windows Vista Ultimate • 128MB Intel GMA 900 UMA Graphics
-
May 16th, 2008, 01:36 PM
#2
Re: Listbox Adding
Is this what you are looking for?
Code:
Public Sub ServerDataParse(SiteFile As String)
Open SiteFile For Input As #1
While Not EOF(1)
Line Input #1, sData
List1.AddItem sData
Wend
Close #1
End Sub
-
May 16th, 2008, 01:56 PM
#3
Thread Starter
Lively Member
Re: Listbox Adding
vb Code:
Public Sub ServerDataParse(SiteFile As String) Open SiteFile For Input As #1 While Not EOF(1) Line Input #1, sData Form1.List2.AddItem sData Wend Close #1 End Sub
Open SiteFile For Input As #1
Bad file name or number.
Did a reply help answer your questions? Please RATE good posts!
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
New Laptop System: Intel Dual-Core T2060 2.0GHz • 533MHz FSB • 2MB Cache • 1024MB RAM • 120GB Hard Drive • Dual Layer DVD ReWriter MultiDrive • 15.4" Widescreen Display • Microsoft Windows Vista Ultimate • 128MB Intel GMA 900 UMA Graphics
-
May 16th, 2008, 02:30 PM
#4
Re: Listbox Adding
What does SiteFile contain?
-
May 16th, 2008, 02:45 PM
#5
Thread Starter
Lively Member
-
May 16th, 2008, 02:52 PM
#6
Re: Listbox Adding
It seems you misunderstood what I was asking... What value does SiteFile contain at the time of the error?
-
May 16th, 2008, 02:57 PM
#7
Thread Starter
Lively Member
-
May 16th, 2008, 04:16 PM
#8
New Member
Re: Listbox Adding
Just my pennies worth, seems you may have 2 problems
1/
Is the text file accesible by this method via HTTP ?
2/
Public Sub ServerDataParse(SiteFile As String)
DIM i
Open SiteFile For Input As #1
While Not EOF(1)
Line Input #1, sData
if len(sdata) > 1 then 'check that sData actually contains something
for i = 1 to len(sdata)
if mid(sdata,i,1)=chr(10) or if mid(sdata,i,1)=chr(13) then
mid(sdata,i,1)=" "
endif
next
Form1.List2.AddItem trim(sData)
endif
Wend
Close #1
End Sub
-
May 16th, 2008, 04:20 PM
#9
Re: Listbox Adding
sitefile is passed as a string
try like this
vb Code:
Public Sub ServerDataParse(SiteFile As String) dim sitearr() as string sitearr = split(sitefile,chr(10)) For i = 0 To ubound sitearr Form1.List2.AddItem Sitearr(i) next End Sub
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
May 16th, 2008, 04:27 PM
#10
Thread Starter
Lively Member
-
May 17th, 2008, 05:23 AM
#11
Re: Listbox Adding
You asked about a file but you were actually passing a string?
-
May 17th, 2008, 07:40 PM
#12
Re: Listbox Adding
no, the interrnet file was downloaded to string and passed to sub, just his variable name was confusing
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|