vb.net代码集不使用原始文本文件,它只显示字母顺序最高的名称9 x

vb.net代码集不使用原始文本文件,它只显示字母顺序最高的名称9 x,vb.net,console,Vb.net,Console,代码取自我观看的YouTube视频: 代码中没有错误,只是列出了名字Aiden,这是在原始文本文件9个地方写下来的 任何想法都将不胜感激 导入System.IO 模块1 Sub Main() Dim myArray As New List(Of String) Using myReader As StreamReader = New StreamReader(".\myFile.txt") 'telling VB that we're using a Stream

代码取自我观看的YouTube视频:

代码中没有错误,只是列出了名字Aiden,这是在原始文本文件9个地方写下来的

任何想法都将不胜感激

导入System.IO

模块1

Sub Main()
    Dim myArray As New List(Of String)
    Using myReader As StreamReader = New StreamReader(".\myFile.txt")
        'telling VB that we're using a StreamREader, read a line at a time
        Dim myLine As String
        myLine = myReader.ReadLine 'assigns the line to String Variable myLine
        Do While (Not myLine Is Nothing)
            myArray.Add(myLine) 'adding it to the list of words in the array
            Console.WriteLine(myLine)
            myLine = myReader.ReadLine
        Loop
    End Using
    SortMyArray(myArray)
    'Console.ReadLine()
End Sub

Sub SortMyArray(ByVal mySort As List(Of String))
    Dim Tmp As String, writePath As String = ".\sorted.txt"
    Dim max As Integer = mySort.Count - 1
    Dim myWriter As StreamWriter = New StreamWriter(writePath)

    For Loop1 = 0 To max - 1
        For Loop2 = Loop1 + 1 To max
            If mySort(Loop1) > mySort(Loop2) Then
                Tmp = mySort(Loop2)
                mySort(Loop1) = mySort(Loop1)
                mySort(Loop1) = Tmp

            End If
        Next
        myWriter.WriteLine(mySort.Item(Loop1).ToString())
    Next
    myWriter.Dispose()
End Sub

End Module

myortloop1=myortloop1你应该看看这一行来修复你的输入错误谢谢你,谢谢你让我解决了我自己的问题。我的一部分总是想被告知,但我知道,如果我弄明白了,它会更强大: