473,387 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Random Numbers and Adding the Random Numbers Generated

PureCoffee
So here is some code but I can't get past the generation. I would like to add whatever randomely generated numbers are shown in each "private sub".

Obviously I am a NOOB to VB but I rather enjoy the challenges. This has me stumped...

Can someone Please help?
Thanks,
PureCoffee

Public Class Form1

Private Sub btndeal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndeal.Click
Randomize()

Me.lblRandNum1.Text = CStr(CInt(10 * Rnd() + 1))
Me.lblRandNum2.Text = CStr(CInt(10 * Rnd() + 1))

End Sub

Private Sub btndraw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndraw.Click


Me.lblRandNum3.Text = CStr(CInt(10 * Rnd()) + 1)

End Sub

Private Sub btncheckscore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncheckscore.Click


Randomize()
Me.lblRandNum4.Text = CStr(CInt(10 * Rnd() + 1))
Me.lblRandNum5.Text = CStr(CInt(10 * Rnd() + 1))
Me.lblRandNum6.Text = CStr(CInt(10 * Rnd() + 1))


lblpscore.Text = CStr(CInt(lblRandNum1.Text + lblRandNum2.Text))

' lblcscore.Text =


End Sub
End Class
Mar 10 '10 #1
1 1825
kadghar
1,295 Expert 1GB
instead of:

Me.lblRandNum1.Text = CStr(CInt(10 * Rnd() + 1))

use

Me.lblRandNum1.Text &= CStr(CInt(10 * Rnd() + 1)) & " "

this will add them to the label, instead of replacing its content.

Note: if you're using old versions of VB or VBA it should be like this:

Me.lblRandNum1.Text = Me.lblRandNum1.Text & " " & CStr(CInt(10 * Rnd() + 1))
Mar 13 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: james blair | last post by:
Hi I am generating a random number using random.randint(1,10000000000) Whats the possibility that the numbers generated will be same when generated by 100 users at the same time? Whats the best...
21
by: Marc Dansereau | last post by:
Hi all I am new to this forum and to the c programming language. If I understand, the random() function in C return numbers that follow a uniform distribution U(0,1). Can somebody know how to...
13
by: Jon Agiato | last post by:
Hello, I am sure this problem is easy to spot but I have been at this project all day and the frustration has finally overcome me. I am using this function in order to produce a standard normal...
10
by: Marshall Belew | last post by:
I'm trying to synchronize a network app that uses random numbers generated by System.Random. Rather than pass every randomly generated number, I just pass the seed. I'm seeing a result that leads...
5
by: Peteroid | last post by:
I know how to use rand() to generate random POSITIVE-INTEGER numbers. But, I'd like to generate a random DOUBLE number in the range of 0.0 to 1.0 with resolution of a double (i.e., every possible...
104
by: fieldfallow | last post by:
Hello all, Is there a function in the standard C library which returns a prime number which is also pseudo-random? Assuming there isn't, as it appears from the docs that I have, is there a...
12
by: Jim Michaels | last post by:
I need to generate 2 random numbers in rapid sequence from either PHP or mysql. I have not been able to do either. I get the same number back several times from PHP's mt_rand() and from mysql's...
1
by: SpecialEd | last post by:
I'm having trouble adding random numbers that I've generated using a for loop. So far my block of code looks: cout<<"Please enter the number of dice you want to use:"; cin>>numberOFdice;...
12
by: Naya | last post by:
Hi. I am working on a math tutoring program which generates two random numbers (from 1 to 500) and asks the user to add them. How can I check to see whether or not they put in the correct total??...
5
by: coreyover4 | last post by:
I am trying to write a program where I ask the person to input the number of random numbers generated 1-100. Right now I am stuck on one point in particular. How do I write the program to only...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.