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
Solved

text file to series of listboxes

Posted on 2014-02-12
4
219 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

792 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