VB 2008中阅读和拆分资源文本文件中的文本? [英] vb 2008 reading through and splitting text in a resource textfile?

查看:78
本文介绍了VB 2008中阅读和拆分资源文本文件中的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个应用程序,该应用程序在项目的资源部分中创建了一个文本文件,并想知道是否有人可以告诉我如何读取该文本文件并在其中拆分文本?

我尝试了以下两种方法,但在我想将我的文本文件"ResourceFile.txt"的内容显示到名为"FileReader"的文本框中时,它们不起作用.



i have an application where i have created a textfile in the resources section of my project and wanted to know if anyone can tell me how i can read that textfile and split the text in it?

i have tried the following two methods but they don''t work where i am wanting to display the contents of my text file ''ResourceFile.txt'' into a textbox called ''FileReader''.

Dim fileReader As String
fileReader = FileSystem.ReadAllText("ResourceFile.txt")
FileReader.Text.Split(fileReader, " ")







and

Imports system.IO
Dim ioFile as new StreamReader("ResourceFile.txt")
Dim ioLine as string
Dim ioLines as string
ioLine = ioFile.ReadLine
ioLines = ioLine
While not ioLine = ""
ioLine = ioFile.ReadLine
ioLines = ioLines & vbcrlf & ioLine
End While
FileReader.Text.Split = (ioLines, " ")
ioFile.close





thanks to any helpers.

推荐答案

尝试一下:
Try this:
Dim fileReader As String
fileReader = FileSystem.ReadAllText("ResourceFile.txt")
FileReader.Text=fileReader



顺便说一句,拥有一个名为fileReader的字符串和一个名为FileReader的文本框是非常令人困惑和普遍的坏习惯.在发疯之前,您需要开始使用某种命名约定.在您的变量名之前添加一些代码,以区分它是字符串还是文本框.例如,将您的文本框命名为txtFileReader,并将字符串命名为strFileReader.

希望这会有所帮助.



And by the way, it''s very confusing and general bad practice to have a string named fileReader and a textbox named FileReader. You need to start using some kind of naming convention before you go crazy. Put some kind of code before your variable name to distinguish that it''s a string or a textbox. For example, name your textbox txtFileReader and the string strFileReader.

Hope this helps.


这篇关于VB 2008中阅读和拆分资源文本文件中的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆