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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:52:04+00:00 2026-06-18T04:52:04+00:00

Well I have made this random string generate but I have recently noticed a

  • 0

Well I have made this random string generate but I have recently noticed a fatal flaw. When I generate a random string, close the program and generate another random string it is the same as the first generation. Here is the code:

   Public Function RandomString(ByVal length As Integer) As String
    Dim strb As New System.Text.StringBuilder
    Dim chars() As String = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} 

    Dim UpperBound As Integer = UBound(chars)

    For x As Integer = 1 To length
        strb.Append(chars(Int(Rnd() * UpperBound)))
    Next

    Return strb.ToString

End Function

Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
    Try
        System.Diagnostics.Process.Start("Link Removed!")
    Catch
    End Try
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim repeatCnt As Integer

    'Check for valid numeric entry
    If Integer.TryParse(TextBox2.Text, repeatCnt) Then
        For repeatIdx As Integer = 1 To repeatCnt
            Dim rndstring As String
            'Generate random string...
            rndstring = RandomString(24)
            '...and append to text box with a line break
            RichTextBox1.Text &= rndstring & vbCrLf
        Next
    Else
        MessageBox.Show("Please enter a valid integer number in the text box")
    End If
End Sub
  • 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-18T04:52:05+00:00Added an answer on June 18, 2026 at 4:52 am

    Your problem is that you’re running Rnd() instead of using the Random class.

    In order to keep Rnd() from giving the same sequence of “random” numbers every time, Random.Next() should be called (in order to use the machine clock for the initial value / seed).

    So in your case:

    Dim random As New System.Random()
    Public Function RandomString(ByVal length As Integer) As String
       Dim strb As New System.Text.StringBuilder
       Dim chars() As String = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} 
    
       Dim UpperBound As Integer = UBound(chars)
    
       For x As Integer = 1 To length
          strb.Append(chars(Int(random.Next(UpperBound)))
       Next
    
       Return strb.ToString
    
    End Function     
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have made a program in vc++ 2010 in win7 but since the submission
Well, I'm so confused. I have made a json element like this: var world
Well i have made this jquery code $(document).ready(function(){ $(.graduate).keyup(function(e){ if(e.keyCode!=8 && (e.keyCode<48 && e.keyCode>57)){
I have made a search engine which works well, but I want it to
I have an online text editor, very well made however it does not currently
well i have a configuration like this in the components part of my config
Well i have a div tag that i show as a modal dialog this
well i have most probably an extremly stupid problem but could not figure it
Hopefully this will be clear enough. I have a 2d map made of tiles,
I have a query that I have made into a MYSQL view. This particular

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.