I'm trying to make a program that lets user to input an array of lastnames then firstnames. Then display the a list of firstname first, then the lastname. For example:

Input: Smith, John
: Doe, Jane
displays like:
John Smith
Jane Doe

This is what i got so far.

Module Ex04

    Sub Main()
        Dim m As Integer
        Dim anArrayList As ArrayList = New ArrayList(5)
        Dim inputString As String = "!"
        Do While Not inputString.StartsWith("$")
            Console.WriteLine("Enter a full name, Last, First I. - $ to end input")
            inputString = Console.ReadLine()

        For m = 0 To 5
            m = m + 1

    End Sub

End Module

May be you are looking for,

Dim s = "aa,bb,cc,dd"
Dim t = System.Text.RegularExpressions.Regex.Replace(s, "(\w+),(\w+)", "$2,$1")

nope, I'm looking for a split method can that reverse the order of the names. Smith, John will become John Smith

For m = 0 To 5
Dim currentName() as string=anArrayList(m).split(","c)
            Console.WriteLine(String.Format("{0} {1}",currentName(1).trim,currentName(0).trim))
            m = m + 1

But you should ofc check if the input is correct before starting the loops


Here is a different example using an String.empty to stop input, and uses the number of elements in the arraylist for the loop count....

Sub Main()

        Dim nameAL As ArrayList = New ArrayList

        Console.WriteLine("Enter a full name, Last, First")

        Dim emptyLine As Boolean = False
        Dim nameString As String

        Do Until emptyLine = True
            nameString = Console.ReadLine

            If nameString = String.Empty Then
                emptyLine = True
            End If


        'Display Names

        For i As Integer = 0 To nameAL.Count - 1
            Dim alSplit() As String
            alSplit = nameAL(i).ToString.Replace(" ", "").Split(CChar(","))
            Console.WriteLine(alSplit(1) & " " & alSplit(0))



    End Sub