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 8572211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:57:27+00:00 2026-06-11T18:57:27+00:00

I am facing an issue to perform numbers comparison between the integers inputted by

  • 0

I am facing an issue to perform numbers comparison between the integers inputted by user and random numbers generated by the codes.

Each of the integers input by the user should then be compared with the LOTTO numbers to check for a match. A For each… loop needs to be used to achieve this.

After checking all the 7 user input integers against the LOTTO numbers, the total number of matches should be output to the user. If there are no matches the output should read “LOOSER!”.

Here are my codes, I’m currently only stuck at the comparison portion, and we need to use for each loop to achieve this.

Imports System

Module Lotto

Sub Main()

    'Declaration
    Dim numbers(6) As Integer
    Dim IsStarted As Boolean = True

    'Prompt user to enter 
    Console.WriteLine("Please enter your 7 lucky numbers from 0 - 9 ONLY")

    'Use Do While Loop to re-iterate the prompts
    Do While IsStarted
        For pos As Integer = 0 To 6
            Console.Write("Enter number {0}: ", pos + 1)
            'How it stores into an array
            numbers(pos) = Console.ReadLine()

            'Check if it is a number: use IsNumberic()
            If IsNumeric(numbers(pos)) Then 'proceed
                'Check if it is NOT 0 < x > 9
                If numbers(pos) < 0 Or numbers(pos) > 9 Then
                    'Don't proceed
                    Console.WriteLine("Invalid Input")
                    IsStarted = True
                    'When any number is invalid, exit the loop
                    Exit For
                End If
            End If
            IsStarted = False
        Next
    Loop

    'Printing out the array. It can also be written as 
    'For pos = LBound(numbers) To UBound(numbers)
    For pos = 0 To 6
        Console.Write(numbers(pos) & " ")
    Next

    Console.WriteLine()
    'Random number generator
    Randomize()
    Dim random_numbers(6) As Integer
    Dim upperbound As Integer = 7
    Dim lowerbound As Integer = 0
    Dim rnd_number As Double = 0

    For pos = 0 To 6
        rnd_number = CInt((upperbound - lowerbound) * Rnd() + lowerbound)
        random_numbers(pos) = rnd_number

        Console.Write(random_numbers(pos) & " ")
    Next

    'Iterate and compare
    Dim isSame As Boolean = False
    Dim pos2 As Integer = 0
    Dim Counter As Integer = 0

    'For check = 0 To 6
    'If numbers(pos2).Equals(random_numbers(pos2)) Then
    For Each number As Integer In numbers
        'Console.WriteLine(pos2 + 1 & ":" & number & ":")
        If number.Equals(random_numbers(pos2)) Then
            'Console.WriteLine("here is the number that matched:" & number & ":")
            isSame = True
            pos2 = pos2 + 1
        End If

        For Each num As Integer In random_numbers
            If random_numbers Is numbers Then
                Counter = Counter + 1
            End If

        Next
    Next

    Console.WriteLine()

    'Display result
    If isSame = True Then
        Console.WriteLine("The total numbers of matches are: " & Counter)
    Else
        Console.WriteLine("LOOSER!")
    End If
    Console.ReadLine()

End Sub

End Module

  • 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-11T18:57:28+00:00Added an answer on June 11, 2026 at 6:57 pm
                Dim intCursor As Integer = 0
    
                For Each intNumber As Integer In numbers
    
                    'Assumes first user chosen number must equal 
                    'the first random number to be considered a match,
                    'the second user number must equal the second random,
                    'etc (Ordering is a factor).
                    If random_numbers(intCursor) = intNumber Then
    
                        Counter += 1
    
                    End If
    
                    intCursor += 1
    
                Next
    
                If (Counter > 0) Then
    
                    Console.WriteLine("The total numbers of matches are: " & Counter)
    
                Else
    
                    Console.WriteLine("LOOSER!")
    
                End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am facing an issue with h:selectOneRadio's valueChangeListener=#{user.loadYesNo} (I use Mojarra 2-0-8 on Tomcat-7)
I am facing strange issue. I have wep-part that reads data from user's profile.
I am facing issue while i load a form on ajax request. i followed
I have been facing issue with sphinx result set for string attribute. Below is
I got below JSON string, i facing issue parsing because it contains non english
We have implemented webservice which generates xml response. I am facing issue while invoking
Facing some issue in Talend Admin Console, the jobs that are running from IDE
issue facing while loading the messages in to mq channel, recieving an error like
Im facing an issue with The following: public class Person { private long id;
I am facing this issue whenever I am trying to run Play 1.2.1 in

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.