Results 1 to 2 of 2

Thread: Linear Search in VB.NET

  1. #1
    New Member
    Join Date
    Jan 2019
    HSC
    2019
    Gender
    Undisclosed
    Posts
    16
    Rep Power
    1

    Question Linear Search in VB.NET

    Hi, so I've been working on this program on VB.NET to find how many results exist in a list through linear search. I have managed to code to find if something exists in a list, but I'm not sure how you can display the amount of results found in the list, for example, how many John's are in the list of names. Could anybody help me with this? Thank you in advance.

    My current coding is below:

    Private Sub btmLinearSearch_Click(sender As Object, e As EventArgs) Handles btmLinearSearch.Click

    Dim stNames(24) As String

    stNames(0) = "Elf"
    stNames(1) = "Rudolf"
    stNames(2) = "Star"
    stNames(3) = "Grinch"
    stNames(4) = "Angel"
    stNames(5) = "Santa"
    stNames(6) = "Present"
    stNames(7) = "Crackers"
    stNames(8) = "Carol Singers"
    stNames(9) = "Xmas Trees"
    stNames(10) = "Baubles"
    stNames(11) = "Cookies"
    stNames(12) = "Mistletoe"
    stNames(13) = "Carrots"
    stNames(14) = "Milk"
    stNames(15) = "Present"
    stNames(16) = "Sack"
    stNames(17) = "Pudding"
    stNames(18) = "Snowman"
    stNames(19) = "Bilby"
    stNames(20) = "Uluru"
    stNames(21) = "Sleigh"
    stNames(22) = "North Pole"
    stNames(23) = "Candy Cane"
    stNames(24) = "Present"

    Dim stFind As String
    stFind = Me.txtFind.Text

    Dim bFound As Boolean
    For iCount As Integer = 0 To 24
    If stNames(iCount) = stFind Then
    bFound = True
    Exit For
    End If
    Next

    If bFound = True Then
    MsgBox("found " & stFind)
    Else
    MsgBox(stFind & " not found")
    End If
    End Sub

    I want now to make it so that it displays that there are 3 "Presents" in the list.
    Last edited by nakappe; 6 Feb 2019 at 5:42 PM.

  2. #2
    New Member
    Join Date
    Sep 2016
    HSC
    2017
    Gender
    Male
    Posts
    3
    Rep Power
    2

    Re: Linear Search in VB.NET

    is this advent calendar?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •