4 Replies - 905 Views - Last Post: 30 April 2012 - 09:56 PM Rate Topic: -----

#1 Nick8961  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 30-April 12

Search a text file and load a specific line into a list box.

Posted 30 April 2012 - 02:20 PM

I have hit a brick wall and don't know what else to try I have been searching all over the internet for an answer but have found nothing. Here is what I am trying to accomplish. For class we are to create a banking application, you can either save data to flat files, serialization, or a database. I don't know much about database or serialization. So I am using text files to run my banking application.

There are multiple forms: a create account form, close account form, manage account form, and conduct transaction form. What my problem is on the close account form I am supposed to have a search option to search for a specific account number and than then load it into a listbox. Than Then select that line and click close to delete file from account. If anyone has a easier suggestion than using text files please recommend.

This post has been edited by tlhIn`toq: 30 April 2012 - 08:45 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Search a text file and load a specific line into a list box.

#2 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1182
  • View blog
  • Posts: 1,677
  • Joined: 24-August 11

Re: Search a text file and load a specific line into a list box.

Posted 30 April 2012 - 02:47 PM

Members here are more likely to tell you what they think is a "better" suggestion than an "easier" suggestion.

You should really take the opportunity to learn about databases at this point. Do a little research on how to create a SQL Express database in your solution. That will be a necessity in your development career at some point anyway.
Was This Post Helpful? 1
  • +
  • -

#3 Nerfpl  Icon User is offline

  • D.I.C Head

Reputation: 43
  • View blog
  • Posts: 165
  • Joined: 15-January 12

Re: Search a text file and load a specific line into a list box.

Posted 30 April 2012 - 03:16 PM

I can give you brief explanation how SQL Database looks and how easy it is.

  • Database have tables, Something like folders
  • Each of those tables have columns. Something like variables templates
  • Now each row in those tables is a data row which can store stuff in those defined columns.
  • So in the end is similar to Excel sheets and Excel tables (with difference that column pattern is same for all table rows, so there's less free form but it defines structure which is exactly what you want. Name, ,Password, address, etc.)

Now SQL language (which is very easy btw) offers 'very fast' way to find any row you want and read, modify or save its data.

In case of C# there's 'tool' called LINQ which uses syntax nearly same as this in SQL.

But if you want to go easy and not so bad way (depends if this is serious project) you can do something like
*Create yourclass class with any data fields you need, like login, password etc
*Create List<yourclass> accounts. With collection you can easly find item with given index etc using enumeration or even LINQ
*Serialize this 'List<yourclass> accounts' using XML Serialization or better Binary Serialization.

So each time you load application, if given file exists you deserialize the accounts back into 'List<yourclass> accounts' and you serialize either on exit or on modification
Was This Post Helpful? 1
  • +
  • -

#4 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5674
  • View blog
  • Posts: 12,189
  • Joined: 02-June 10

Re: Search a text file and load a specific line into a list box.

Posted 30 April 2012 - 08:52 PM

Quote

What my problem is on the close account form I am supposed to have a search option to search for a specific account number and than then load it into a listbox. Than Then select that line and click close to delete file from account. If anyone has a easier suggestion than using text files please recommend.


Easier or better than what? You described what you are supposed to have. We can't change the requirements of what you are supposed to do, and you haven't described anything about how you plan to accomplish the requirements... shown us your attempts to code this... told us about any errors or exceptions...

Is there a question in there somewhere? - Please read this

  • Q: How do I get Form 'A' to make a change or talk to Form 'B'
  • A:[list]
  • See this thread for the simplest of example code between two forms.


Separating data from GUI - PLUS - serializing the data to XML

90% or more of the problems we see here are because rookies don't stop and plan nor block out their code into logical segments.
This article should help you see a way to block out your code by stubbing out the methods and logic, then filling in each method as you research it:
This is the 'Help me with my homework' article you wanted.
Was This Post Helpful? 1
  • +
  • -

#5 Nick8961  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 30-April 12

Re: Search a text file and load a specific line into a list box.

Posted 30 April 2012 - 09:56 PM

Thanks guys for all the comments and help. I would of responded earlier but had a hiccup at the household. I am going to try the different options yall mentioned. Thanks Again.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1