我想将变量存储到数组中(VB.NET)

时间:2014-01-04 16:45:59

标签: arrays vb.net csv multidimensional-array

我希望我的程序将输入存储到csv文件中,如下所示:

我写了一个词,例如字

我写了一个定义,例如定义

然后我写了5个错误,例如错误1,错误2,错误3,错误4,错误5。

所以它看起来像这样:

字,定义,错误1,错误2,错误3,错误4,错误5

字2,定义3,错误1,错误2,错误3,错误4,错误5

 Dim decision As Char
    Dim fullline As String = " "

    Dim word(9), def(9), minorerror(49) As String

    Console.Clear()

    Console.WriteLine("Select the year you will be saving the test for: ")
    Console.WriteLine()
    Console.WriteLine("3 - Year 3")
    Console.WriteLine("4 - Year 4")
    Console.WriteLine("5 - Year 5")
    Console.WriteLine("6 - Year 6")


    Console.WriteLine()


    Dim testyear As Integer = Console.ReadLine()

    Select Case testyear

        Case 1
        Case 2
        Case 3
        Case 4

    End Select

    Console.WriteLine("Please enter 10 of your selected words, defenitions and selected amount minor errors to be featured in the following test")

    FileOpen(5, "F:\Computing\Spelling Bee\testtests.csv", OpenMode.Append)

    Do

        counter = counter + 1
        Console.Write("Word: ")
        word(counter) = Console.ReadLine
        Console.Write("Defenition: ")
        def(counter) = Console.ReadLine

        Console.WriteLine("Type in a max of 5 minor errors")

        For i As Integer = 1 To 5

            Console.Write("Minor error 1: ")
            minorerror(i + i) = Console.ReadLine
            'Console.Write("Minor error 2: ")
            'minoerror2(counter) = Console.ReadLine
            'Console.Write("Minor error 3: ")
            'minoerror3(counter) = Console.ReadLine
            'Console.Write("Minor error 4: ")
            'minoerror4(counter) = Console.ReadLine
            'Console.Write("Minor error 5: ")
            'minoerror5(counter) = Console.ReadLine

        Next

    Loop Until counter = 9
    Console.Clear()

    Dim x As Integer

    For counter As Integer = 0 To 9
        fullline = word(counter) & "," & def(counter) & "," & minorerror(x + counter)
        PrintLine(5, fullline)
        ' Console.WriteLine("Word: " & (word(counter.ToString)) & " Defenition: " & (def(counter.ToString)) & " Minor error 1: " & (minorerror1(counter.ToString)))
    Next

    Console.WriteLine("Are you sure you want to save this test? (y/n) ")
    decision = Console.ReadLine
    If decision = "y" Or decision = "Y" Then
        FileClose(5)
        staffmenu()
    ElseIf decision = "n" Or decision = "N" Then
        addtest()

我已经坚持了一段时间,我的文字和定义被存储得很好,只是错误。

我对编码很新,并希望得到任何帮助。

0 个答案:

没有答案