Solved

checking for existing strings in a textfile in vb2005

Posted on 2008-10-05
6
199 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

867 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

19 Experts available now in Live!

Get 1:1 Help Now