VB Scripting Help?

Discussion in 'Scripting' started by HORIZONTAL THINKER, Nov 4, 2013.

  1. HORIZONTAL THINKER

    HORIZONTAL THINKER MDL Member

    Jun 13, 2012
    155
    29
    10
    #1 HORIZONTAL THINKER, Nov 4, 2013
    Last edited by a moderator: Apr 20, 2017
    Hello everyone,

    Below is a small script i'm using to learn how to build simple key-gens. I'm new to VB and am still fumbling around quite a bit:

    Code:
    TextBox1.Text = Int(Rnd() * 9)
    Select Case TextBox1.Text
    Case 0
    TextBox1.Text = "1key"
    Case 1
    TextBox1.Text = "2key"
    Case 2
    TextBox1.Text = "3key"
    Case 3
    TextBox1.Text = "4key"
    Case 4
    TextBox1.Text = "5key"
    Case 5
    TextBox1.Text = "6key"
    Case 6
    TextBox1.Text = "7key"
    Case 7
    TextBox1.Text = "8key"
    Case 8
    TextBox1.Text = "9key"
    End Select
    The issue i'm having is that using this script sometimes calls the same key a number of times. What modification would i need to make to the script so as generated keys are called sequentially rather than randomly?

    My thinking is that the below line of code is what needs to be modified:

    Code:
    TextBox1.Text = Int(Rnd() * 9)
    Thanks for any help you may provide :)
     
  2. gitguy

    gitguy MDL Novice

    Dec 13, 2013
    2
    0
    0
    is this a homework assignment?

    but anyway if your using arrays dont you need to determine them then create a seperate function to call them?

    im kinda rusty at vb. its been a while

    but something like


    TextBox1.Text = Int(9)
    Select Case TextBox1.Text
    Case 0
    TextBox1.Text = "1key"
    Case 1
    TextBox1.Text = "2key"
    Case 2
    TextBox1.Text = "3key"
    Case 3
    TextBox1.Text = "4key"
    Case 4
    TextBox1.Text = "5key"
    Case 5
    TextBox1.Text = "6key"
    Case 6
    TextBox1.Text = "7key"
    Case 7
    TextBox1.Text = "8key"
    Case 8
    TextBox1.Text = "9key"
    End Select

    if (textbox1 <=9) do your logic here
     
  3. Mazzif

    Mazzif Elitebook Pwner

    Oct 18, 2013
    322
    441
    10
    I guess Im confused by the Random vs Sequential aspect. Are you saying that after a random key value (1-9) is determined, then next key you call, you'd like it to be whatever your Selected Case + 1?