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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:28:58+00:00 2026-05-27T03:28:58+00:00

I created a small vb.net console app in visual studio 2008 trying to learn

  • 0

I created a small vb.net console app in visual studio 2008 trying to learn .net but my results show differently when I break in the code and press F11 to step through. If I do it this way, the results I expect to get show but if I don’t break into the code the results aren’t what I’m expecting.

Basically everytime I click a button i want to write four numbers that are random. If I break into the code, these show random numbers i.e. 1 3 4 3 but if i don’t break into the code. my numbers are all the same i.e. 1 1 1 1.

Here is my code, like I said I’m still learning so the logic is probably not correct.

Module Module1

Dim number1 As Integer = 0
Dim _DiceRolled As Boolean = False
Dim number2 As Integer = 0
Dim number3 As Integer = 0
Dim number4 As Integer = 0
Dim numberArray() As Integer = {number1, number2, number3, number4}

Sub Main()

    Dim quit As Boolean = False
    Dim cki As ConsoleKeyInfo
    Do While quit = False
        If diceRolled = False Then
            Console.WriteLine("Press any key to roll the dice...")

            cki = Console.ReadKey


            If cki.KeyChar <> "q" Then
                quit = False
            Else
                quit = True
                Exit Do
            End If

            roll()
            diceRolled = True

        Else
            Console.WriteLine("Press any key to roll the dice again...")
            cki = Console.ReadKey
            If cki.KeyChar <> "q" Then
                quit = False
            Else
                quit = True
                Exit Do
            End If

            roll()
        End If
    Loop
    Console.WriteLine(" Game is over!")
    Console.ReadKey()


End Sub


Private Sub roll()
    Dim newNumbers(4) As Integer
    Dim stringbuilder As String = ""
    Console.Write(" New numbers : ")
    Dim count As Integer = 0
    stringbuilder = ""

    For Each number As Integer In numberArray


        newNumbers(count) = (generateRandomNumber(number))
        stringbuilder += (newNumbers(count).ToString() + " ")
        count += 1

    Next
    Console.Write(stringbuilder)
End Sub

Private Function generateRandomNumber(ByVal number As Integer)
    Dim rand As New Random
    number = rand.Next(1, 5)
    Return number
End Function

Private Property diceRolled()
    Get
        Return _DiceRolled
    End Get
    Set(ByVal value)
        _DiceRolled = value
    End Set
End Property


End Module

Any ideas? Thanks

  • 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-05-27T03:28:59+00:00Added an answer on May 27, 2026 at 3:28 am

    You’re making a new Random instance for each random number.

    By default, Random creates a seed from the current time.
    Your code runs fast enough that all of the Randoms get the same seed.

    When you step through it, the steps add pauses between the Randoms, so they get different seeds.

    You should reuse the same Random instance in a Shared field.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a small application using Microsoft .NET. I don't have problems with
I've created small database under SQL Server 2008 . Now i wanted to move
I have created a small application which opens,reads and creates Excel files. The app
I have created a small chatting application in C#, and started as a Console
I have created a small and simple android app. I tried installing it on
I'm a small developer and all of the asp.net solutions I've created run on
What's the recommended way to deploy a website created with ASP.NET 4.0 and Visual
I am from VB.Net WinForms comming. Now I wanted to write a small app
not so long ago I´ve created a small iphone app for my Daily use.
I need to create a small app or script to install a .NET assembly

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.