Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > adding to list box


Reply
 
Thread Tools Display Modes
  #1  
Old 09-23-2005, 06:30 PM
rplp4 rplp4 is offline
Junior Contributor
 
Join Date: Apr 2005
Posts: 247
Default adding to list box


I have a list box that I am trying to add data to from a txt file. I am doing this on two forms. The one form everything works the second form it does not.

text file: only the 7th line is add to the list box
Customer name:Coustomer name
Customer name:Job name
Customer name:8
Customer name:.375
Customer name:0
Customer name:1
1,B,30,30,12,1
end of cabinet list
1|B|12|30|1|R Side|1|0|0|0,0,0,0|0|1|1|1|0|0|0|0|0|.375
1|B|12|30|1|L Side|2|0|0|0,0,0,0|0|2|2|2|0|0|0|0|0|.375
1|B|12|28.5|1|Bottom|0|1|0|1,0,1,0|1|0|0|3|0|0|0|0|0|.375
1|B|6.5|28.5|2|Top|0|1|0|1,0,1,0|0|0|0|5|0|0|0|0|0|.375
1|B|28.5|28.5|1|Back|0|1|0|1,1,1,1|0|0|0|6|0|0|0|0|0|.375
1|B|10.5|28.5|2|Shelf|0|0|0|0,0,0,0|0|0|0|8|0|0|0|0|0|.375

when I load this into the list box I appear to split the line on the ,'s
The list box looks like this:
1
B
30
30
12
1
Code:
Public Sub Command1_Click() ''''''''''''''''''''''''''''''''''''''''''''''''' Dim whatfile As String Dim cablist As String whatfile = NoCollision.Tag Open whatfile For Input As #1 For p = 0 To txtCoustomername.Count - 1 Line Input #1, Coustomername Coustomername = Split(Coustomername, ":") txtCoustomername(p).Text = Coustomername(1) Next p For l = 1 To txtCoustomername(4).Text - 1 Load P1(l) P1(P1.Count - 1).Visible = True Next l '''''''''''''''''''''''' Do Input #1, cablist If cablist = "end of cabinet list" Then 'MsgBox "this is it" Else lstcabinets.AddItem (cablist) End If Loop Until cablist = "end of cabinet list" '''''''''''''''''''' HScroll1.Max = txtCoustomername(4).Text Do i = 1 + i Line Input #1, parts part = Split(parts, "|") For e = LBound(part) To UBound(part) With optimizegrid .TextMatrix(i, e) = part(e) End With Next e optimizegrid.Rows = optimizegrid.Rows + 1 If optimizegrid.TextMatrix(i, 17) > "0" Then Call optimizegrid_DblClick i = 1 - i End If Loop Until EOF(1) Close #1
What is happening?

Last edited by herilane; 09-24-2005 at 04:02 AM. Reason: Replaced [code] tags with [vb]
Reply With Quote
  #2  
Old 09-24-2005, 04:01 AM
herilane's Avatar
herilane herilane is offline
Unashamed geek

Retired Moderator
* Expert *
 
Join Date: Jul 2003
Location: London, England
Posts: 8,988
Default

That's because you are using Input to read the cablist, instead of Line Input. Input reads one variable at a time, and assumes that variables are separated by commas. Therefore each item in that comma-separated list is, well, treated as a separate item.

PS: Could you please use [vb][/vb] to format your code, instead of [code] tags? Proper formatting makes code a lot easier to read.
Reply With Quote
  #3  
Old 09-24-2005, 06:04 AM
rplp4 rplp4 is offline
Junior Contributor
 
Join Date: Apr 2005
Posts: 247
Default

Thank you, It looks like I used line input on the form that is working.
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->