Support Forums
Reading a text doc? - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Visual Basic and the .NET Framework (https://www.supportforums.net/forumdisplay.php?fid=19)
+---- Thread: Reading a text doc? (/showthread.php?tid=13682)

Pages: 1 2 3


RE: Reading a text doc? - KoBE - 11-13-2010

(11-13-2010, 02:44 PM)Xzotic Wrote: I really think that it would be easier in the end to just code it in the program itself. Put it in a function so all you have to do is call a function. Of course that would take more planning that just what i said. Might need to add a few more variables and statements, but overall I think it is a better method. You would still have to read it from the file everytime + have the information in the file.

I agree, unless you plan on changing the level values after the program has been built, or through settings of some sort. I think the best way would be to hard code it, and think of a way to incorporate how much the exp goes up into what level they are on into a function. If you really want code on how to read from a text I will give it to you, but reading the text is just the beginning. You will have to specify the data to only pull what you need per level.


RE: Reading a text doc? - pers2981 - 11-13-2010

(11-13-2010, 03:05 PM)the_GENie Wrote: I agree, unless you plan on changing the level values after the program has been built, or through settings of some sort. I think the best way would be to hard code it, and think of a way to incorporate how much the exp goes up into what level they are on into a function. If you really want code on how to read from a text I will give it to you, but reading the text is just the beginning. You will have to specify the data to only pull what you need per level.
Actually i wanted 3 text files one named exp-easy one named exp-hard etc and each one would be harder/easier


RE: Reading a text doc? - KoBE - 11-13-2010

Code:
Dim reader As System.IO.StreamReader
Dim filename As String = "exp-easy.txt"
reader = System.IO.File.OpenText(filename)
textbox1.Text = reader.ReadToEnd
reader.Close()

Here, this will get you started. This will open a textfile named exp-easy.txt and load it into a textbox. Adapt it to suit your needs.


RE: Reading a text doc? - pers2981 - 11-13-2010

(11-13-2010, 03:22 PM)the_GENie Wrote:
Code:
Dim reader As System.IO.StreamReader
Dim filename As String = "exp-easy.txt"
reader = System.IO.File.OpenText(filename)
textbox1.Text = reader.ReadToEnd
reader.Close()

Here, this will get you started. This will open a textfile named exp-easy.txt and load it into a textbox. Adapt it to suit your needs.

Thanks but where is the exp-easy.txt saved?


RE: Reading a text doc? - Xzotic - 11-13-2010

Same place as your program, or it wont work unless you specify the location.


RE: Reading a text doc? - pers2981 - 11-13-2010

I see
could i make the .txt a .dat?


RE: Reading a text doc? - KoBE - 11-13-2010

(11-13-2010, 03:40 PM)pers2981 Wrote: I see
could i make the .txt a .dat?

Yes, as long as it's saved as exp-easy.dat and you have it loaded in using the code above it will act the same way as a txt file.


RE: Reading a text doc? - pers2981 - 11-13-2010

kk Thanks Smile Going to attempt to add this in when i get home@!


RE: Reading a text doc? - JMK940 - 11-14-2010

I think it would be more stable if you wrote the whole thing out.


RE: Reading a text doc? - pers2981 - 11-14-2010

(11-14-2010, 04:36 AM)JMK940 Wrote: I think it would be more stable if you wrote the whole thing out.
all 999 levels :L