Private Sub btnQ5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQ5.Click

Dim enterText As String

Dim i As Integer

Dim stringArray() As String

Dim Shortest As String

Dim Longest As String

Dim x As Integer

enterText = InputBox("Please enter some text")

stringArray = enterText.Split(" ")

For i = 0 To stringArray.Length - 1

MsgBox(stringArray(i))

Next

'This is the part i am having trouble with

Shortest = stringArray(LBound(stringArray))

Longest = stringArray(LBound(stringArray))

For x = 0 To stringArray.Length - 1

If Len(Shortest) < Len(stringArray(x)) Then Shortest = stringArray(x)

If Len(Longest) > Len(stringArray(x)) Then Longest = stringArray(x)

Next

lstOut.Items.Add(Shortest)

lstOut.Items.Add(Longest)

End Sub