I'm trying to make diceware generator. Need some help.

• Question

• Well, the program is fully functional but there are few things that I need help with.

First:

Dim myRand1As Integer

myRand1 = generator.Next(11111, 66666)

This code should simulate the dice throw 5 times. But in this randomizer, I get 0,7,8 and 9 numbers which are not usable with diceware design.

Second:

I need somehow make a connection to my website's SQL that I can use same logins from the database that is registered with a forum.

• Edited by Tuesday, October 17, 2017 11:47 AM Some grammar fails -.- :D
Tuesday, October 17, 2017 11:45 AM

All replies

• Well, the program is fully functional but there are few things that I need help with.

First:

Dim myRand1As Integer

myRand1 = generator.Next(11111, 66666)

This code should simulate the dice throw 5 times. But in this randomizer, I get 0,7,8 and 9 numbers which are not usable with diceware design.

Second:

I need somehow make a connection to my website's SQL that I can use same logins from the database that is registered with a forum.

Hi

Those two lines of code mean absolutely nothing!

Is 'Generator' defined as a 'New Random' somewhere?

You seem to want to assign a number between 11111 and  66666 to 'myRand1' - how does that relate to results of '0,7,8 and 9'?

Here is a snippet showing how to create a list of 100 random numbers between 1 and 6 inclusive.

```Option Strict On
Option Explicit On
Public Class Form1
Dim Generator As New Random
Dim lst As New List(Of Integer)
' create 100 random numbers between 1 and 6 inclusive
For i As Integer = 1 To 100
Next
End Sub
End Class```
BTW: start a new thread for a second question.

Regards Les, Livingston, Scotland

Tuesday, October 17, 2017 12:19 PM
• This code should simulate the dice throw 5 times. But in this randomizer, I get 0,7,8 and 9 numbers which are not usable with diceware design.

The Next method does not work how you have assumed it works.  The code you have posted will create a single random number between 11111 and 66666.  To get a sequence of five random numbers between 1 and 6 you need to call the Next method 5 times with arguments (1,7).

Your second question should be posted in a new thread, and probably in a more suitable forum with much more detail.

Tuesday, October 17, 2017 8:43 PM
• Well, the program is fully functional but there are few things that I need help with.

First:

Dim myRand1As Integer

myRand1 = generator.Next(11111, 66666)

This code should simulate the dice throw 5 times. But in this randomizer, I get 0,7,8 and 9 numbers which are not usable with diceware design.

Second:

I need somehow make a connection to my website's SQL that I can use same logins from the database that is registered with a forum.

```Module Module1
Dim RNG As New Random
Sub Main()
Dim resp As String = ""
Do
For roll = 0 To 4
Console.Write(RNG.Next(1, 7).ToString & vbTab)
Console.WriteLine(RNG.Next(1, 7).ToString)
Next
Console.WriteLine("Again (Y/N)")
Loop Until resp.ToLower = "n"
End Sub
End Module
```
That's possibly a start.

Tuesday, October 17, 2017 10:39 PM
• Hi Leakoni,

If you want to get random number from 1 to 6, and show 5 time, you can refer to the following code:

```Dim random As New Random()
Dim i As Integer
For i = 0 To 4
MsgBox(Convert.ToString(random.Next(1, 7)))
Next```