VB Script Help?
#1
Hello all,

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 in using this script , it calls the same key a number of times. What modification would i need to make to the script so the stored 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)

If you have a solution could you post the full script so i can test it and try and learn the proper systax etc.

Thanks for any help you may provide Big Grin
Reply
#2
I'm not sure what you're trying to achieve with that code exactly.

So you're generating a random number between 0 and 8 and assigning it to TextBox1's Text property, and then depending on the number you again change the Text property to a different string.

What are you trying to do?
Reply
#3
(Nov 05, 2013, 15:48 pm)esharoth Wrote: I'm not sure what you're trying to achieve with that code exactly.

So you're generating a random number between 0 and 8 and assigning it to TextBox1's Text property, and then depending on the number you again change the Text property to a different string.

What are you trying to do?

Cheers esharoth. Here's what i'm trying to achieve. Below would be an example of the way i would like things to run.

1. I click on generate and get the serial which would be 1key
2. I click on generate again and get the serial which would be 2key
3. I click on generate again and get the serial which would be 3key and so on.

As the code is now. It randomly selects between 1key and 9key. A lot of the time giving the same key 2-3 times in a row. I would like it so each time the generate button is clicked. It gives the next key in the sequence and not just pick a random key.
Reply
#4
Create a string array of 9 elements and store the keys in the array. Use a variable as a counter for the current array element, and every time you click on the generate button you increase the counter and return the array element which has the counter as its index (making sure you don't go over the array size so you don't try to access an element which doesn't exist).

So you might have something like this:

Code:
Dim strKeys(0 to 8) As String

strKeys(0) = "1key"
[...]
strKeys(8) = "9key"

Dim counter as Integer = -1

And the generate button onclick event might look like this:

Code:
Private Sub Generate_Click()
  counter += 1
  if counter > 8 then counter = 0
  TextBox1.Text = strKeys(counter)
End Sub
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  https ssl algorithm entirely in java/script ejonessss 4 22,476 Nov 14, 2016, 15:56 pm
Last Post: blu_people
  Batch Script to Convert File Extensions LowOrbit 9 29,127 Apr 16, 2015, 03:43 am
Last Post: bob5695
  What script do major trackers use ? mgtow 1 16,170 Nov 26, 2014, 07:54 am
Last Post: NIK
  Script to decrypt encrypted images in a flash viewer? ninchuck 0 14,925 Nov 29, 2013, 20:19 pm
Last Post: ninchuck



Users browsing this thread: 1 Guest(s)