• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

checking for existing strings in a textfile in vb2005

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
dizzycat
Asked:
dizzycat
  • 2
  • 2
1 Solution
 
elimesikaCommented:
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
 
dizzycatAuthor Commented:
I think next time I will as i find using textfiles difficult.
0
 
elimesikaCommented:
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
 
dizzycatAuthor Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now