Solved

checking for existing strings in a textfile in vb2005

Posted on 2008-10-05
6
198 Views
Last Modified: 2010-04-23
Hi Experts

I have a textfile with the format :
PlayerName1,PlayerName2,GameType,
On my form I have 3 textboxs: PlayerName1 and PlayerName2 and GameType
I want to add the contents of the textboxs to the textfile but not if:
(A)PlayerName1 and PlayerName2 are already in the textfile(on the same row).
(B)PlayerName1 and GameType are already in the textfile(on the same row).
(C)PlayerName2 and GameType are already in the textfile(on the same row).

I know this is difficult but hope somebody can help.


0
Comment
Question by:dizzycat
  • 2
  • 2
6 Comments
 
LVL 19

Expert Comment

by:elimesika
Comment Utility
HI

Before getting to the point, did you consider using a database table instead of your text file?
It just the sort of problems that database is the natural tool to use with....
0
 

Author Comment

by:dizzycat
Comment Utility
I think next time I will as i find using textfiles difficult.
0
 
LVL 19

Accepted Solution

by:
elimesika earned 500 total points
Comment Utility
OK

Assuming you are familiar with VB coding, what you have to do is

1) define a structure as your file row (PlayerName1,PlayerName2,GameType)
2) Define a List of structures of the type defined in 1
3) In the Form_Load Read the file line by line, parse using the string.split on the comma separator and fill the List you have created in 2)
4) when the user enters new text and press the form button , loop the list and check all needed checking (that is easy to do in memory)
5) If check is passed , append the row to the file and add the corresponding entry to your List
6) Do not forget to close the file handle when you close the form.

Good Luck
0
 

Author Comment

by:dizzycat
Comment Utility
The above sounds good but I at least need some code to get me started, then maybe I can build from there.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now