|
-
Apr 22nd, 2004, 10:28 AM
#1
Simple question about text files [RESOLVED... finally..]
Fairly simple concept here: I have a text file with lots of **** written in it. 9 pages worth of data to describe 120 items, basically. So, how do I get VB to search for a particular line of text? I seem to be remembering something about a SearchLine command, but I'm not sure. Any help would be an awesome use in the making of a great game!!!
Last edited by timeshifter; Apr 22nd, 2004 at 03:12 PM.
-
Apr 22nd, 2004, 10:40 AM
#2
Hyperactive Member
Here goes nothing man.
VB Code:
Set FSO = CreateObject("Scripting.FileSystemObject")
Set fl = FSO.OpenTextFile(FilePath & "\" FileName, 1, False)
While Not fl.AtEndOfStream
ContentsOfLine = fl.ReadLine
Wend
That should grab your file line by line
If this post helps, please RATE MY POST!
Using Visual Studio 2005 SE
-
Apr 22nd, 2004, 10:43 AM
#3
Okay, let me define what I need a little better. I have this massive text file filled with numbers, kinda like an ini file, except the program only goes to it when it needs a value. I need it to search for something, say [Bronze] and then it'll read the values from that point for two lines, getting the values it needs. How does that work out
-
Apr 22nd, 2004, 10:53 AM
#4
Frenzied Member
Not sure why you want to start a new thread when all the information is already in your other one
http://www.vbforums.com/showthread.p...hreadid=287252
The problem is the way you are designing your .txt file. You are making it hard to retrieve the data you are searching for. Fix that problem and make your life easy.
-
Apr 22nd, 2004, 10:57 AM
#5
Addicted Member
I agree with Brianz
if that is not for you though, you could always pull the file into a richtext box and search that.
Not so fast, but the larger the file, the richtext solution should start to make more sence.
Simon
-
Apr 22nd, 2004, 01:40 PM
#6
Are you saying that I should just have the target text, say [Bronze], and have only the values in the lines afterwords, with no describing text??
-
Apr 22nd, 2004, 03:02 PM
#7
Final Question
I've opened the completed text file, and I know exactly where to look to get the information I need. Now, could someone please tell me how to have VB search the open text file for a string????
-
Apr 22nd, 2004, 03:11 PM
#8
Problem finally solved, took me forever to figure it out, but here it is...
VB Code:
Private Sub txtEnemyName_KeyPress(KeyAscii As Integer)
Dim temp As String
If KeyAscii = 13 Then
Open "S:/2005/205508/Text Documents/Crusader.sta.txt" For Input As #1
Do
Line Input #1, temp
Loop Until temp = "[" & txtEnemyName.Text & "]"
Line Input #1, temp
lblStrengthLevel = temp
Line Input #1, temp
lblRangedLevel = temp
Line Input #1, temp
lblMagicLevel = temp
Line Input #1, temp
lblDefenseLevel = temp
Line Input #1, temp
lblHP = temp
Close 1
End If
End Sub
I settled for just making the text file have the enemy name and then the numbers, no descriptions. It would appear to work better...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|