Solved

text file to series of listboxes

Posted on 2014-02-12
4
218 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
  • 2
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
dustock earned 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

778 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