【发布时间】:2015-02-06 00:34:26
【问题描述】:
我现在找到了解决我之前问题的方法,但我现在需要更多帮助。我想将用户输入的字符串与文本文件中的字符串列表进行比较。我成功了,但现在我想做相同,但不是文件系统中的文本文件,而是我希望它位于应用程序资源中。我确实找到了一种读取资源文本文件的方法,并通过使其在消息框中输出内容来确认它,但现在当我替换普通的流阅读器代码,它读取应用程序所在的资源文件并且什么都不做,而不是给出一个消息框,确认它找到了一个字符串匹配,就像在文件流代码中一样。这是我现在所拥有的:
Imports System.IO
Imports System.Resources
Imports System.Reflection
Public Class Form1
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
'The original stream reader code bit that worked:Dim Lines As String = IO.File.ReadAllLines("1.txt")
Dim Lines As String = My.Resources.ResourceManager.GetObject("_1")
'Above is the new resource reader code that is in place of old stream reader IO code
For Each line As String In Lines 'Every time the program reads a new line from the textfile database
If line = TextBox1.Text Then'if a line from the text file 'matches that with the textbox input
MsgBox("works")'user confirmation it matched
GoTo A'jumps to "A:" to end the "for" loop
Else
End If
Next
A:'where the jump leads to
End Sub
End Class
【问题讨论】:
标签: database vb.net string resources compare