Question Actions based on elements within a text file (array)

shinobi1173

New member
Joined
Jul 15, 2012
Messages
2
Programming Experience
Beginner
Alright... I've been battling this for quite a while now. I am usually able to find the answers for any of my questions in this website but not for the passed 2 days! Ok, here we go...

I am trying to do 2 things:

  • I have a text file (Books.txt) and I am trying to create an application to display fiction and nonfiction (separately) books within a listbox. The text file reads this:

Left Behind,Lahaye,F,7,11.25
A Tale of Two Cities,Dickens,F,100,8.24
Hang a Thousand Trees with Ribbons,Rinaldi,F,30,16.79
Saffy's Angel,McKay,F,20,8.22
Each Little Bird that Sings,Wiles,F,10,7.70
Abiding in Christ,Murray,N,3,12.20
Bible Prophecy,Lahaye and Hindson,N,5,14.95
Captivating,Eldredge,N,12,16
Growing Deep in the Christian Life,Swindoll,N,11,19.95
Prayers that Heal the Heart,Virkler,N,4,12.00
Grow in Grace,Ferguson,N,3,11.95
The Good and Beautiful God,Smith,N,7,11.75
Victory Over the Darkness,Anderson,N,12,16

The third to the last element either says "F" for fiction or "N" for nonfiction. I am trying to write a code to where the application looks into the text file, checks to see if element 3 is either an "F" or an "N", and posts only the title of the book (the first element) in the listbox.

I've been searching and searching and cannot find the friggin code!!! Help!!! Please!!!

For example reasons, my listbox is named lstInventory. thanks!
 
You can use the TextFieldParser class, to insert a standard code snippet using this class write (in a procedure) filParseText and press TAB.
You can of course also do a basic loop through File.ReadAllLines and use String.Split method.
 
my listbox is named lstInventory

Do I take it from this that what you're looking to do is add all the titles into a single listbox with one section above the other? If so how do you intend the user to recognise where one section finishes and the other starts? I note that the text file appears to be sorted in this manner. Is this awlays the case?
 
Back
Top