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

  • SEARCH
  • Home
  • 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 8452395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:29:20+00:00 2026-06-10T11:29:20+00:00

Dim keys1() As String = {corrupt, selfish, power, lying, lies, media} Dim terms1 As

  • 0
    Dim keys1() As String = {"corrupt", "selfish", "power", "lying", "lies", "media"}
    Dim terms1 As Integer = 0
    Dim terms1string As String = ""
    terms1string = Console.ReadLine()
    For Each st As String In keys1
        terms1 = terms1 + 1
    Next
    If terms1 < 2 Then
        Console.WriteLine("yay!")
    Else
        Console.WriteLine("YouFail")
    End If

Theres my code. I’d like it to be that if your string entered has more than two of those terms, then it writes “Yay”– otherwise it writes “YouFail.”

—update 8/29/12—

    Function StageTwo(ByVal fname, ByVal lname, ByVal city)
    Console.WriteLine("Describe the U.S. Government.")
    Dim overall As Integer = 0
    Dim keys1() As String = {"corrupt", "selfish", "power", "lying", "lies", "media"}
    Dim terms1 As Integer = 0
    Dim terms1string As String = ""
    terms1string = Console.ReadLine()
    For Each st As String In keys1
        If InStr(terms1string, st) > 0 Then '<<<this line right here!
            terms1 = terms1 + 1
        End If
    Next
    If terms1 < 0 Then
        Console.WriteLine("yay!")
        overall = overall + 1
    End If
    Console.WriteLine()
    Console.WriteLine("Describe the economic status in the U.S.")
    Dim keys2() As String = {"broken", "backed", "failed", "skewed", "tilted", "99%", "rigged", "unfair"}
    Dim terms2 As Integer = 0
    Dim terms2string As String = ""
    terms2string = Console.ReadLine()
    For Each st As String In keys2
        If InStr(terms2string, st) > 0 Then '<<<this line right here!
            terms2 = terms2 + 1
        End If
    Next
    If terms2 < 0 Then
        Console.WriteLine("yay!")
        overall = overall + 1
    End If
    If overall = 2 Then
        Console.WriteLine()
        Console.WriteLine("Enter a username.")
        Dim username As String = ""
        username = Console.ReadLine()
        Console.WriteLine("Please wait.")
        IsURLValid(username, overall)
    Else
        Console.WriteLine("Test Failed.")
    End If
    System.Threading.Thread.Sleep(2000)
End Function

That’s my fresh code. Still not working, it’s printing test failed after entering corrupt for the first one and broken for the second one. Help again?
Thanks so much guys.

  • 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. Editorial Team
    Editorial Team
    2026-06-10T11:29:21+00:00Added an answer on June 10, 2026 at 11:29 am

    Why so complicated? Just use Count:

    Dim keys1() As String = {"corrupt", "selfish", "power", "lying", "lies", "media"}
    Dim terms1string = Console.ReadLine()
    
    Dim terms1 = keys1.Count(function(key) terms1string like "*" & key & "*")
    
    If terms1 < 2 Then
        Console.WriteLine("yay!")
    Else
        Console.WriteLine("YouFail")
    End If
    

    If you want to match the single words (foobar power lies are 2 matches, foobarpowerlies are 0 matches), you can use this line instead:

    Dim terms1 = keys1.Count(function(key) terms1string.Split().Contains(key))
    

    For completeness, here’s a regex version:

    ' generous match ('foobarpowerlies' => 2 matches)
    Dim pattern = String.Join("|", keys1)
    Dim terms1 = Regex.Matches(terms1string, pattern).Count
    

    or

    ' strict match using word boundaries ('foobarpowerlies' => 0 matches, but 'foobar power lies' => 2 matches)
    Dim pattern = String.Join("|", keys1.Select(function(key) "\b" & key & "\b"))
    Dim terms1 = Regex.Matches(terms1string, pattern).Count
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

dim dataType as String toolTip=Marks And Number[String] I want to get the [String] alone.
Dim insert_coupon_query As String = (INSERT INTO qa_discountcoupons (id, status_code) VALUES (AUTO_INCREMENT_ID, 5)) Dim
Dim i as integer For i = 0 to 365 sqlinsert.InsertCommand=insert into cashdate (date)
Dim CustID As String = txtSrchCustID.Text Dim FirstName As String = txtNewCustFName.Text Dim SecondName
Dim datatable_default_view As DataTable = _datatable.DefaultView.ToTable Dim servicenumber As String = datatable_default_view.Rows.Item(e.RowIndex)(Service Number).ToString 'gets
Consider a loop where you aggregate strings into a comma separated value string: Dim
I have a string I need to get array (2 - dim) of key->value
Hi I have this dictionary.. Dim Rooms As New Dictionary(Of Integer, Of Integer) Rooms(1)
Dim dtmStart As Date, dtmEnd As Date, dblDuration As Double dtmStart = 1900/01/01 08:10:00
Dim classCodeDetails As List(Of ClassCodeDetail) = db.ClassCodeHeaders.Single(Function(cch) cch.CLCH_ID = classCodeHeaderId ).ClassCodeDetails.ToList() classCodeDetails.Sort(Function(c1, c2) c1.Make.MAKE_English.CompareTo(c2.Make.MAKE_English)

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.