![]() |
VB - Import Text From .txt file? -- Help! - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Visual Basic & .NET Framework (https://sinister.ly/Forum-Visual-Basic-NET-Framework) +--- Thread: VB - Import Text From .txt file? -- Help! (/Thread-VB-Import-Text-From-txt-file-Help) |
VB - Import Text From .txt file? -- Help! - Morpheus_mybb_import11112 - 03-20-2013 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" 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: ![]() 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 RE: VB - Import Text From .txt file? -- Help! - ArkPhaze - 03-21-2013 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") RE: VB - Import Text From .txt file? -- Help! - ddee - 03-21-2013 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 RE: VB - Import Text From .txt file? -- Help! - ArkPhaze - 03-21-2013 (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: I think you mean StreamReader, not FileReader. RE: VB - Import Text From .txt file? -- Help! - ddee - 03-21-2013 Quote:I think you mean StreamReader, not FileReader. That is right! ![]() |