比较一个文件到另一个文件

时间:2016-02-21 18:49:04

标签: vb.net visual-studio visual-studio-2010

我制作的表格基本上是用户提高韩国数字技能的活动。我有一个文件,其中有10个英文数字,​​另一个文件有10个数字用韩文翻译。到目前为止,我已经随机化了5个标签,以便从文件中的10个数字中选出5个数字作为列表。

当用户回答问题时,我遇到问题,如果用户得到的答案正确,那么应该出现勾选图像,但检查用户是否有正确答案的代码不起作用。当用户在AnswerBox1中输入正确的值时,它不会显示一个勾号,它应该检查用户是否得到了正确的答案。

Public Class Form1
    Dim rand As New Random
    Dim attempt As Integer
    Dim a As Integer
    Dim QuestionFile As New IO.StreamReader(CurDir() & "\" & "NumbersQ.txt")
    Dim fileContentsQ As String = QuestionFile.ReadToEnd
    Dim fileListQ As New List(Of String)
    Dim AnswerFile As New IO.StreamReader(CurDir() & "\" & "NumbersA.txt")
    Dim fileContentsA As String = AnswerFile.ReadToEnd
    Dim fileListA As New List(Of String)
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        For Each Str As String In fileContentsQ.Split(CChar(vbCrLf))
            fileListQ.Add(Str)
        Next
        For Each Str As String In fileContentsA.Split(CChar(vbCrLf))
            fileListA.Add(Str)
        Next
        Dim randItem As Integer = rand.Next(0, fileListQ.Count - 1)
        Question1.Text = (fileListQ.Item(randItem))
        fileListQ.RemoveAt(randItem)
        'removes the question from the list so that the question won't be repeated
        a = randItem
        Solution1.Text = fileListA.Item(a)
        'a hidden label which contains the answer to the question
        fileListA.RemoveAt(a)
    End Sub

    Private Sub CheckAnswers_Click(sender As System.Object, e As System.EventArgs) Handles CheckAnswers.Click
        If AnswerBox1.Text = Solution1.Text Then
            Tick1.Show()
        End If
    End Sub
End Class

0 个答案:

没有答案