So, here is what I came up with...
Spoiler
Module Module1 Public Sub Main() Dim s1, s2, s3 As String Dim o1, o2, o3 As String Dim c1, c2, c3 As Short o1 = "" o2 = "" o3 = "" 'Generate random names to test program Dim name() As String = {"tom", "dick", "harry", "adam", "Eve", "derek", "steve", "vic", "melissa", "brad", "stephanie", _ "ashley", "bobby", "margaret", "cloe", "karen", "brandon", "clair", "zoe", "sara", "lisa", _ "bill"} s1 = name(GetRandomNumber(0, name.Length - 1)) s2 = name(GetRandomNumber(0, name.Length - 1)) s3 = name(GetRandomNumber(0, name.Length - 1)) 'Console.WriteLine("Enter name 1.") : s1 = Console.ReadLine 'Console.WriteLine("Enter name 2.") : s2 = Console.ReadLine() 'Console.WriteLine("Enter name 3.") : s3 = Console.ReadLine() Console.WriteLine(vbNewLine & vbNewLine & "First round" & vbNewLine _ & "++++++++++++++++++++++++++++++++++++++++++++++") Console.WriteLine(vbNewLine & "Initial values : {0} s1 = {1} {0} s2 = {2} {0} s3 = {3}", vbNewLine, s1, s2, s3) 'First ompare strings to see if the order is clear c1 = CShort(String.Compare(s1, s2, True)) c1 = c1 + CShort(String.Compare(s1, s3, True)) c2 = CShort(String.Compare(s2, s1, True)) c2 = c2 + CShort(String.Compare(s2, s3, True)) c3 = CShort(String.Compare(s3, s1, True)) c3 = c3 + CShort(String.Compare(s3, s1, True)) 'If there is a tie among them check to see who comes first If c1 = c2 Then If String.Compare(s1, s2) <= 0 Then c1 -= c1 End If ElseIf c1 = c3 Then If String.Compare(s1, s3) <= 0 Then c1 -= c1 End If End If If c2 = c3 And s2 < s3 Then If c2 = 2 Then c2 = c2 + CShort(2) c3 = c3 - CShort(2) ElseIf c2 = 0 Then c3 = c3 + CShort(1) ElseIf c2 = -2 Then c3 = c3 + CShort(2) End If ElseIf c2 = c3 And s3 < s2 Then If c3 = 2 Then c3 = c3 - CShort(2) ElseIf c3 = 0 Then c2 = c2 + CShort(1) ElseIf c3 = -2 Then c2 = c2 + CShort(2) End If End If 'Display the totals for the comparison Console.WriteLine("c1 totals {0}", c1) Console.WriteLine("c2 totals {0}", c2) Console.WriteLine("c3 totals {0}", c3) 'Based on the counter place each name into their respective order slot If c1 < 0 Then o1 = s1 ElseIf c1 = 0 Then o2 = s1 ElseIf c1 > 0 Then o3 = s1 End If If c2 < 0 Then o1 = s2 ElseIf c2 = 0 Then o2 = s2 ElseIf c2 > 0 Then o3 = s2 End If If c3 < 0 Then o1 = s3 ElseIf c3 = 0 Then o2 = s3 ElseIf c3 > 0 Then o3 = s3 End If 'Display names in ascending order Console.WriteLine("o1 = {0}", o1) Console.WriteLine("o2 = {0}", o2) Console.WriteLine("o3 = {0}", o3) 'The far simpler way Using the array method 'Console.WriteLine(vbNewLine & vbNewLine & vbNewLine & "Using an Array") 'Dim names(2) As String 'Dim i As Short = 1 'names = {s1, s2, s3} 'Array.Sort(names) 'For Each name In names ' Console.Write("Name {0}:" & vbTab, i) ' Console.WriteLine("{0}", name) ' i = CShort(i + 1) 'Next Console.ReadKey() End Sub 'Generate random order of names to insert into name values Dim objRandom As New System.Random( _ CType(System.DateTime.Now.Ticks Mod System.Int32.MaxValue, Integer)) Public Function GetRandomNumber( _ ByVal Low As Integer, _ ByVal High As Integer) As Integer ' Returns a random number, ' between the optional Low and High parameters Return objRandom.Next(Low, High + 1) End Function End Module
Anyone else?