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

The Archive Base Latest Questions

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

I have come here asking for help on how to make my string generator

  • 0

I have come here asking for help on how to make my string generator generate the amount of strings typed in TextBox2. For example, if I typed 10 in the box it would generate 10 strings in the RichTextBox1 and if I typed 1 it would generate 1 etc. Here is my 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 rndstring As String
    rndstring = RandomString(24)
    RichTextBox1.Text = rndstring
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:10:22+00:00Added an answer on June 18, 2026 at 4:10 am

    What you need to do is modify your click handler for Button1 to repeat the number of times specified in TextBox2. However, you should verify that the user specified a valid numeric value in the text box as well. Something like this:

    Private Sub Button1_Click(sender As System.Object, 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
                TextBox1.Text &= rndstring & vbCrLf
            Next
        Else
            MessageBox.Show("Please enter a valid integer number in the text box")
        End If
    End Sub
    

    An extra suggestion might be to change the text box that the user specifies the repeat value to a NumericUpDown control.

    Also note that, for large repeat values, the append to the text box Text property would not be efficient due to string immutability so perhaps another StringBuilder would be appropriate.

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

Sidebar

Related Questions

I'm new to posting on these forums but have come here multiple times for
thanks for the past help. I am asking you again. I want to have
I know there have been many questions asking for help converting URLs to clickable
I have finally perfected my extension for Chrome, after asking 2 questions here. I
I have come across an annoying problem. I have made a system and now
I have come to know from book that for declaring a structure variable it
I have come across scripts that use: isset($_POST['submit']) as well as code that uses:
I have come across the following basic Tree conflict: Local add, incoming add upon
I have come across many articles which warn against using links to provide logout
I have come across loop-unrolling but what other types of compiler optimization are there

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.