Jump to content

Recommended Posts

Posted

Ok i've got the code bellow for "Visual Basic 2008" but i want it to generate numbers from a list ".txt" ex. "NumberList.txt" "1, 2, 3, 4 - ,999999"

I dont want it to randomize nmbers !

Public Class Form1

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Timer1.Start()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Timer1.Stop()
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Interval = ("5000")
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Interval = ("2500")
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Timer1.Interval = ("1500")
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        SendKeys.Send(Int(Val(TextBox1.Text) * Rnd()))
        SendKeys.Send("{enter}")
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

Posted

You mean you want it to read a .txt file with numbers?

Lets say the txt file contains this:

1
2
3
4
5
6

 

You want your program to read those numbers and post them line by line in a textbox or listbox?

Posted

for generating random numbers use RND (example: rnd() * 50000, output will be between 0 and 50000)

 

and for +1 all the time just use a simple loop for that (i just know it for C++,,, dont know atm for vb lol but you maybe will get my point :P)

 

for(unsigned int i = 0; i < 50000; i++)

{

//Here the numbers will go +1 till 50000

//out put will be:

// 0

// 1

// 2

// 3

// 4

//.....

}

Posted

for generating random numbers use RND (example: rnd() * 50000, output will be between 0 and 50000)

 

Yeah only this could generate real numbers too. (I got 33553.37 as random number)

The way to do it properly for integers is this:

Dim minimum_number As Integer = 1
       Dim maximum_number As Integer = 10
       Dim random_number As New Random
       MsgBox(random_number.Next(minimum_number, maximum_number))

or for a random number between 1 and 10 could be done easier

       Dim random_number As New Random
       MsgBox(random_number.Next(1, 10))

or for a function:

Function GenerateRandomNumber(ByVal minimum_number As Integer, ByVal maximum_number As Integer) As Integer
       Dim rnd As New Random : Return rnd.Next(minimum_number, maximum_number)
End Function

 

 

Posted

i dont want random numbers !! i want 1 to 9999999 but thx for help

You mean this?

For i = 1 to 9999999
'Do something here
next i

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...