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

checking for existing strings in a textfile in vb2005

Posted on 2008-10-05
6
203 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
ID: 22645983
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
ID: 22645998
I think next time I will as i find using textfiles difficult.
0
 
LVL 19

Accepted Solution

by:
elimesika earned 500 total points
ID: 22646082
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
ID: 22704818
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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