Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

text file to series of listboxes

Posted on 2014-02-12
4
Medium Priority
?
222 Views
Last Modified: 2014-02-12
i have  text file that contains the previously saved contents of a group of listboxes.

here is a sample

ListBox4
ListBox3
06410 3x5 SAFETY                                        
06416 3x4 RED                                          
06418 3x4 BROWN                                        
06458 3x4 BLUEMIST                                      
ListBox2
06420 4x6 RED                                          
06421 4x6 BROWN                                        
06423 3x10 BROWN                                        
06425 3x4 SLATE                                        
06434 3x5 COFFEE                                        
06440 3x5 GREETING                                      
06443 3x4 NAVY                                          
06444 4x6 NAVY                                          
06445 3x10 NAVY                                        
ListBox1
06426 4x6 SLATE                                        
06428 3x10 SLATE                                        
06429 4x6 CHURCH&CHURCH  
MainListBox
01234 3x5 TURQUOISE                                    
06399 0x0 NOT-IN-SERVICE                                
06459 4x6 BLUEMIST                                      
06460 3x10 BLUEMIST                                    
06473 4x6 ROUNDBROWN                                    
06474 3x10 ROUNDBROWN                                  
06476 3x4 ROUNDBROWN                                    
06485 3x4 DESIGNERBLUE                                  
06486 4x6 DEIGNERBLUE                                  
06487 3x10 DESIGNERBLUE                                
06491 3x4 DESIGNERBROWN                                
06492 4x6 DESIGNERBROWN                                
06493 3x10 DESIGNERBROWN                                
08008 3x5 ESCBURGUNDY                                  
08028 3x10 ASHEVILLEPOLICE                              
08038 4x6 SHARPESLAWNLOGO                              
08040 4x6 H.T.HACKNEY                                  
08043 4x6 ABTECH                                        
08053 4x6 BB&T                    



what i want to do is read through the file and repopulate the appropriate listboxes with the text lines below each listbox

my question is .. .how do i get the string i read in to map to the corresponding list box on my form.

here is what i have so far

                FileOpen(fileNum, "c:\ini\" + txtSaveFile.Text.ToString, OpenMode.Input)
                Do Until EOF(fileNum)
                    fileString = LineInput(fileNum)
                    If fileString.StartsWith("List") Or fileString.StartsWith("main") Then
                        BoxString = fileString
                    Else
                        'point to listbox contained in  -BoxString
                        'add filestring to that listbox
                    End If
                Loop
0
Comment
Question by:CASorter
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
dustock earned 2000 total points
ID: 39854151
Make boxString a global variable, in your else add the InsertData(fileString) and also make sure to add the new subroutine InsertData.  Also make sure to put an upper case M in main or check against the lower case value.


                FileOpen(fileNum, "c:\ini\" + txtSaveFile.Text.ToString, OpenMode.Input)
                Do Until EOF(fileNum)
                    fileString = LineInput(fileNum)
                    If fileString.StartsWith("List") Or fileString.StartsWith("Main") Then
                        BoxString = fileString
                    Else
                        InsertData(fileString)
                    End If
                Loop 


    Private Sub InsertData(fileString As String)
        Select Case boxString
            Case "ListBox1"
                ListBox1.Items.Add(fileString)
            Case "ListBox2"
                ListBox2.Items.Add(fileString)
            Case "ListBox3"
                ListBox3.Items.Add(fileString)
            Case "ListBox4"
                ListBox4.Items.Add(fileString)
            Case "MainListBox"
                MainListListBox.Items.Add(fileString)
            Case Else
        End Select
    End Sub

Open in new window

0
 

Author Comment

by:CASorter
ID: 39854181
now...  thats thinking "outside the box"

lol...

thanks

let you know if it works....


i would consider this an "old school" solution...  which is good.. i like that better...

but i never know when i should look for System.Reflection.Assembly.GetExecutingAssembly().Location to get the equivalant of the old app.path.....
0
 

Author Closing Comment

by:CASorter
ID: 39854338
thank you!
0
 
LVL 9

Expert Comment

by:dustock
ID: 39854402
No problem, glad my old school style came in handy!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question