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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:13:29+00:00 2026-06-14T04:13:29+00:00

I have to come up with a program that shifts names in a text

  • 0

I have to come up with a program that shifts names in a text box a random amount of times. I have gotten everything up to the point where the names shifts a random amount of times. It only shifts its once, but my messagebox appears through the code as many times as the names should be shifting once i click ok. Does anyone know why the loop is not working for the name shifts. I was thinking maybe the messagebox needs to control the loop, but I have searched endlessly and cannot find how that would be done. Any suggestions or referrals to other sites would be nice thanks. My code is below.

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim RandomNumber As Integer
    Dim min, max As Integer
    Dim temp, temp2, temp3, temp4, temp5, temp6 As String
    Dim i As Integer

    min = 3
    max = 11

    Randomize()
    RandomNumber = Int((max - min + 1) * Rnd() + min)

    temp = n1.Text
    temp2 = n2.Text
    temp3 = n3.Text
    temp4 = n4.Text
    temp5 = n5.Text
    temp6 = n6.Text

    For i = 0 To RandomNumber - 1
        n1.Text = temp6
        n2.Text = temp
        n3.Text = temp2
        n4.Text = temp3
        n5.Text = temp4
        n6.Text = temp5
        MessageBox.Show("Shift " & i & " of " & RandomNumber & " complete")
    Next

End Sub

End Class

  • 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-14T04:13:30+00:00Added an answer on June 14, 2026 at 4:13 am

    Think the temp variables should also be in the loop

    For i = 0 To RandomNumber - 1
    
    temp = n1.Text
    temp2 = n2.Text
    temp3 = n3.Text
    temp4 = n4.Text
    temp5 = n5.Text
    temp6 = n6.Text  
    
        n1.Text = temp6
        n2.Text = temp
        n3.Text = temp2
        n4.Text = temp3
        n5.Text = temp4
        n6.Text = temp5
        //MessageBox.Show("Shift " & i & " of " & RandomNumber & " complete")
    Next
    

    UPDATE

    You can also do it this way using one temp variable

    For i = 0 To RandomNumber - 1
    
      temp = n6.Text
    
      n6.Text = n5.Text
      n5.Text = n4.Text
      n4.Text = n3.Text
      n3.Text = n2.Text
      n2.Text = n1.Text
      n1.Text = temp
    
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that sorts input lines lexicographically, and I've come to this
I have a program that inputs text and sorts through it using a number
I have come to a point in my program where my polymorphism is broken.
While making my program i have come across this requirement that i have to
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 a program that allows the user to execute SQL scripts. I have
I have a program that when an edit button is pressed the window goes
I have a C# program that works correctly on xp and vista but it
I have to make a program that sorts a collection of songs by runtime.

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.