Hi guys. i have a problem. I have developed a program for college which allows a user to enter text and from that text entered i have to find and display the longest and shortest string. I have split the string and sorted it into an array but how do i find the longest and shortest string. Any help would be greatly appreciated. ThanksHow do i find and display the longest and shortest string using vb.net?
Dim sShortest as String, sLongest as String, i as Integer
'MyArray is your array of text strings
sShortest = MyArray(LBound(MyArray))
sLongest = MyArray(LBound(MyArray))
For i = LBound(MyArray) + 1 to UBound(MyArray)
If Len(sShortest) %26gt; Len(MyArray(i)) Then sShortest = MyArray(i)
If Len(sLongest) %26lt; Len(MyArray(i)) Then sLongest = MyArray(i)
Next i
No comments:
Post a Comment