[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

return word in string > 1

Posted on 2011-03-19
1
Medium Priority
?
287 Views
Last Modified: 2012-06-27
How can I find out if a string contain words more than one time? Sample: one, two, three, four, five, two, one,six,seven, etc<br /><br />Result <br />One and two
0
Comment
Question by:VBdotnet2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 13

Accepted Solution

by:
gamarrojgq earned 500 total points
ID: 35173723
Hi,

According to your String Example, you can do it with the code below

Hope that helps
Dim strSample As String = "one, two, three, four, five, two, one,six,seven"
        Dim alCountWords As New ArrayList
        Dim htTimes As New Hashtable
        Dim vecWords() As String
        Dim intWord As Integer
        Dim strWord As String

        vecWords = strSample.Split(",")
        For intWord = 0 To vecWords.Length - 1
            strWord = vecWords(intWord).Trim
            If alCountWords.Contains(strWord) Then
                htTimes(strWord) = Int32.Parse(htTimes(strWord).ToString) + 1
            Else
                htTimes.Add(strWord, 1)
                alCountWords.Add(strWord)
            End If
        Next

        Dim strResults As String = ""
        For intWord = 0 To alCountWords.Count - 1
            If htTimes(alCountWords(intWord)) > 1 Then
                strResults &= alCountWords(intWord) & ","
            End If
        Next

        MsgBox(strResults)

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question