VB.net (help needed) random numbers into textbox

  • Thread starter Deleted member 11215
  • Start date
D

Deleted member 11215

Guest
ok im trying to get this program to put a random number between 1 & 10 into a text box when i click a button so can someone please help. can someone post a code template. cheers.
 

barmyarmy

Retired Administrator
Joined
Mar 12, 2003
Location
Edinburgh
This is what I use:

Code:
Dim r As New Random(System.DateTime.Now.Millisecond)
Dim a as byte
a = (r.Next(0, 4))

Obviously change it for 1 and 10.
 

WORLD CHAMPIONS

PC Battrick Cup Champion S17
Joined
Dec 2, 2006
Location
India
Online Cricket Games Owned
  1. Don Bradman Cricket 14 - Steam PC
duded64 said:
ok im trying to get this program to put a random number between 1 & 10 into a text box when i click a button so can someone please help. can someone post a code template. cheers.



U got that Dude ;)
 
D

Deleted member 11215

Guest
ive got

Code:
score.Text = Val(score.Text) + (a = (r.Next(1, 10)))

with the other two bits at the top of the form but it just keeps staying at 0, any ideas?
 
D

Deleted member 11215

Guest
ive come across another problem. im trying to load data from another combobox into a different form.

im trying to do it with select cases. is this correct?
 

barmyarmy

Retired Administrator
Joined
Mar 12, 2003
Location
Edinburgh
You'll need the form prefix. Form you are using is me. and the other one might be frmMain.cbocombobox.items.clear()
 
D

Deleted member 11215

Guest
i dont understand am i supposed to be doing this:

Code:
  Select Case Form1.cboovers.Items.Clear()
            Case a
        End Select
 

barmyarmy

Retired Administrator
Joined
Mar 12, 2003
Location
Edinburgh
No, that's not going to return a value. You'd need to use something like form1.cboovers.selectedindex

What exactly are you trying to do anyway?
 

Harrypotter_fan

Panel of Selectors
Joined
Sep 12, 2005
Location
Kolhapur, India
Online Cricket Games Owned
Did u get what i said on yahoo?
Code:
Dim RndNo as integer,intVal as Integer
Randomize
RndNo=Int(Rnd*9)+1
intVal=TextBox1.Text
intVal=intVal+RndNo
TextBox.Text=intVal

Here TextBox1 is the name of the textbox

duded64 said:
ive come across another problem. im trying to load data from another combobox into a different form.

im trying to do it with select cases. is this correct?

Code:
Form1.cboBox.Text=Form2.lblBox.Caption
 
Last edited:

Users who are viewing this thread

Top