Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


VB - Import Text From .txt file? -- Help! filter_list
Author
Message
VB - Import Text From .txt file? -- Help! #1
Hey guys, just 2 quick questions.

1. This is quite hard to explain, but I am making a program and for my project, there could be a ton of text coding involved. But I want to just import it fro ma text document to make life a lot easier. Like so:

Code:
TextBox.Text = "get text here line 1"
  TextBox.Text = "get text here line 2"
  TextBox.Text = "get text here line 3"
  TextBox.Text = "get text here line 4"
  TextBox.Text = "get text here line 5"
  TextBox.Text = "get text here line 6"
  TextBox.Text = "get text here line 7"
  TextBox.Text = "get text here line 8"
  TextBox.Text = "get text here line 9"
  TextBox.Text = "get text here line 10"

Now, is there a way to get information from a text document, added to my program, on each line, to fill in for each "my text here line #"?
Confusing, but here's a picture to explain:
[Image: IA1YZIW.png]

So import the text from the text document for each line, into where it would go in the VB script. If you are still unsure, then reply a question and I'll try to answer my best. It really hard to explain what I'm trying to get haha.

**

2. Now for this program, I was wondering if I have my finished project and the text document in the same folder. The program uses the text document in the source code to run properly. If I crypt that text document and bind it to my finished program, will it run correctly? This may be a stupid question, but it seems to me that my program wouldn't be able to read the text document's information if it is crypted. I'm not trying to hide anything, it just makes it a hell of a lot easier than typing out all of the code into the VB form when I could just import it.

Let me know! Thanks,

-Kevin

Reply

RE: VB - Import Text From .txt file? -- Help! #2
You would never assign to:
Code:
TextBox.Text

So is this all the same TextBox or a bunch of different TextBoxes?

If it's all the same use File.ReadAllText() to copy the string over to the control. If it is different TextBoxes, I would index from File.ReadAllLines().

Might look something like this...
Code:
Dim lines As String() = File.ReadAllLines("FILEPATH")
For i As Integer = 0 To lines.Length - 1
    Me.Controls("TextBox" + i.ToString()).Text = lines(i)
Next
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: VB - Import Text From .txt file? -- Help! #3
Just use a File Reader to grab your text. After this, if I understand your clue you need to manipulate each line. So, go on like this:
Code:
Do Until yourSTRING Is Nothing
  yourSTRING = FILEREADER.ReadLine()
Loop
Replace yourSTRING with a list or whatever control (with the appropriate code change) you like to store the info. If you need further assistance just ask for it.

Reply

RE: VB - Import Text From .txt file? -- Help! #4
(03-21-2013, 09:43 AM)ddee Wrote: Just use a File Reader to grab your text. After this, if I understand your clue you need to manipulate each line. So, go on like this:
Code:
Do Until yourSTRING Is Nothing
  yourSTRING = FILEREADER.ReadLine()
Loop
Replace yourSTRING with a list or whatever control (with the appropriate code change) you like to store the info. If you need further assistance just ask for it.

I think you mean StreamReader, not FileReader.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: VB - Import Text From .txt file? -- Help! #5
Quote:I think you mean StreamReader, not FileReader.

That is right! Wink
// hack the planet

Reply







Users browsing this thread: 1 Guest(s)