By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,824 Members | 2,410 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,824 IT Pros & Developers. It's quick & easy.

Hello Guys! I have a question how can i display or print out the longest Capitol Citi

P: 1
This is my code it works but need to change it to allow user input of Fife Cities and display the longest one. Thank you for your help

Expand|Select|Wrap|Line Numbers
  1. Module Module1
  2.  
  3.     Sub Main()
  4.         Dim arrCities As Array = {"Edinburgh", "Kirkcaldy", "Glasgow", "Stirling", "Dundee"}
  5.  
  6.         Console.Write("Longest Word: ")
  7.         Console.Write(LongestWord(arrCities))
  8.         Console.Read()
  9.     End Sub
  10.  
  11.     Function LongestWord(ByVal arrValues As Array)
  12.         Dim strLongest As String = ""
  13.  
  14.         For Each word As String In arrValues
  15.             If Len(word) > Len(strLongest) Then
  16.                 strLongest = word
  17.  
  18.             End If
  19.         Next
  20.  
  21.         Return strLongest
  22.     End Function
  23.  
  24.  
  25. End Module
Mar 16 '16 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.