Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 166977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:11:34+00:00 2026-05-11T12:11:34+00:00

Hey i’m having problems creating a simple button for a programme which finds the

  • 0

Hey i’m having problems creating a simple button for a programme which finds the largest word in an array and puts it into a textbox. I’ve done most of the coding (I hope) was wondering if somebody could help me actually with the code that finds the largest text in the array as I am struggling the most with that.

    Private Sub btnLongName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLongName.Click         Dim LongName As String         Dim LengthOfLongestName As Integer         Dim UltimateName As String           For i As Integer = 0 To 5             LongName = Members(i).Name             LengthOfLongestName = Len(LongName)             If Members(i).Name.Length > LengthOfLongestName Then                End If         Next i          txtResult.Text = 'The longest name is ' & UltimateName & ' .'     End Sub End Class 

Thanks for your time – its for college homework, struggling big time on it 🙁

edit: I’ve edited the code

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T12:11:35+00:00Added an answer on May 11, 2026 at 12:11 pm

    Since this is homework, I won’t write the code for you; instead I’ll try to give you some hints that will point you in the right direction.

    1. Declare a variable of an appropriate type to hold the <longest value so far>, initialize it with the ‘shortest’ value for that type.
    2. Loop through all the values in the array (perhaps with a For or For Each loop)

    Pseudo-code for the inside your loop:

    If the Length of <the value being checked> exceeds _    the Length of the <longest value so far> Then      Assign <the value being checked> to the <longest value so far>   End If 

    When the loop finishes, the <longest value so far> will be the longest value in the array.

    Notes

    • You can use MSDN as a reference on how to use a For loop or a For Each loop (If you haven’t learned For loops yet, you can also use a Do Loop)
    • <the value being checked> will be different on each iteration through the loop; it should correspond to each consecutive value in your array. You can verify that this is working by setting a breakpoint.
    • You can get the length of a string by saying myString.Length
    • If you’ve learned about Functions, consider writing a function that takes an array as a parameter, and returns the longest value in the array.
    • There are certainly ways you could do this with LINQ, but I don’t think that is the goal of the assignment ;-]

    In response to Edit 1:

    • Your If statement needs to be inside of some sort of loop (For, For Each, Do, etc) I think this is the key concept that you are missing.
    • Instead of comparing LongName.Length to LengthOfLongestName, you need to compare the length of an entry in your array to LengthOfLongestName
    • You’re on the right track with Members(0).Name.Length, but you can’t just check element 0; you have to check every element in the array.
    • Given your current code, you’ll probably be assigning <An entry in your array>.Name to LongName
    • The last index in a one-dimensional array is <array>.Length - 1 or <array>.GetUpperBound(0).

    The following doesn’t really address anything in your assignment, but I hope it will give you some ideas on how to go through all the items in your list:

    ' A For loop that does a message box for each of the numbers from 0 to 5 ' For i as Integer = 0 To 5    MessageBox.Show(i) Next i  ' Code that does a message box with the names of the 2nd, 3rd and last ' ' entries in Members ' ' (Remember that the first item is at 0, the second item is at 1, etc...) ' MessageBox.Show(Members(1).Name) MessageBox.Show(Members(2).Name) MessageBox.Show(Members(Members.GetUpperBound()).Name) 

    In response to Edit 2:

    You’re getting warmer…

    • You should only update LongName and LengthOfLongName if the current value is the longest you’ve seen so far (i.e. they should be assigned inside of the If statement)
    • You have to go to the last index of the array, not 5. See above (the response to your first edit) on how to get that last index.
    • You don’t really need the UltimateName variable; you can just use LongName ;-]
    • You might want to use <stringVariable>.Length instead of Len(<stringVariable>) to be consistent.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 178k
  • Answers 178k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Bind the TabItem.Visibility in the RowDetailTemplate to the ContactType using… May 12, 2026 at 3:34 pm
  • Editorial Team
    Editorial Team added an answer In the simplest solution you can fill in parameters to… May 12, 2026 at 3:34 pm
  • Editorial Team
    Editorial Team added an answer Using zfill(): Return the numeric string left filled with zeros… May 12, 2026 at 3:34 pm

Related Questions

Hey I have a windows server running python CGI scripts and I'm having a
Hey I was wondering if there were any way to upload images in ASP?
Hey I usually run into a situation where I will create a class that
Hey I am developing an desktop application using Spring and Hibernate, and I have
Hey i have this div that shows as a popup: <div class=popup> </div> Then

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.