Solved

checking for existing strings in a textfile in vb2005

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

809 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