Hi there,
I have a problem displaying the correct random values extracted from the database. I'm using arrayRandom that stores left250 values and make it appear 90% of the time. arrayReallyRand om stores left250 values and appears 60% of the time. I have a combo box and a list of names. For eg. when i select Mark (the first name on the combo box), it will retrieve AC250L, store it as left250 and store it in arrayRandom and arrayReallyRand om. If user select 60% radiobutton, it will use values from arrayReallyRand om. Else if user select 90% radioButton, it will display values from arrayRandom. Let say, Mark's left250 value is 0, it will display values of 0 or 5. When i select the next name on the list, for eg. John, and John has a left250 value of 50, it should display values of 50 or 55. However, it always display 0 or 5. In fact, all the names is showing values of 0 or 5. How do i resolve that? - Dim randomObject As New System.Random()
-
Private arrayRandom(9) As Integer
-
Private arrayReallyRandom(9) As Integer
-
Dim s As Integer
-
-
-
'AC
-
Dim left250 As Integer
-
-
-
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
-
'TODO: This line of code loads data into the 'SowmyaDataSet.thresholdTable' table. You can move, or remove it, as needed.
-
Me.ThresholdTableTableAdapter.Fill(Me.SowmyaDataSet.thresholdTable)
-
-
Dim con As New OleDb.OleDbConnection
-
Dim ds As New DataSet
-
Dim da As New OleDb.OleDbDataAdapter
-
Dim sql As String
-
-
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Sowmya.mdb;Jet OLEDB:Database Password=geez"
-
-
-
con.Open()
-
-
sql = "SELECT * FROM thresholdTable"
-
da = New OleDb.OleDbDataAdapter(sql, con)
-
da.Fill(ds, "Sowmya")
-
-
con.Close()
-
-
s = Me.ComboBox1.SelectedIndex
-
-
'AC
-
left250 = ds.Tables("Sowmya").Rows(s).Item("AC250L")
-
-
-
'90%
-
arrayRandom(0) = left250
-
arrayRandom(1) = left250
-
arrayRandom(2) = left250
-
arrayRandom(3) = left250
-
arrayRandom(4) = left250
-
arrayRandom(5) = left250
-
arrayRandom(6) = left250
-
arrayRandom(7) = left250
-
arrayRandom(8) = left250 + 5
-
arrayRandom(9) = left250 + 5
-
-
'60%
-
arrayReallyRandom(0) = left250
-
arrayReallyRandom(1) = left250
-
arrayReallyRandom(2) = left250
-
arrayReallyRandom(3) = left250
-
arrayReallyRandom(4) = left250
-
arrayReallyRandom(5) = left250
-
arrayReallyRandom(6) = left250 + 5
-
arrayReallyRandom(7) = left250 + 5
-
arrayReallyRandom(8) = left250 + 5
-
arrayReallyRandom(9) = left250 + 5
-
-
End Sub
-
-
Private Function randomNumber(ByVal rUpper As Integer, ByVal rLower As Integer) As Integer
-
-
' Generate random number between upper and lower bound values
-
Randomize()
-
randomNumber = Int(rUpper * Rnd() + rLower)
-
End Function
-
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
-
Dim RndNum As Integer
-
-
-
If Me.RadioButton90.Checked = True Then
-
RndNum = randomNumber(9, 0)
-
Me.Label1.Text = arrayRandom(RndNum)
-
-
ElseIf Me.RadioButton60.Checked = True Then
-
RndNum = randomNumber(9, 0)
-
Me.Label1.Text = arrayReallyRandom(RndNum)
-
-
End If
0 1111 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Trythat |
last post by:
This might seem a stupid question but here goes -
I wrote a key generator for one of my programs in Visual Basic, so I recieve
sales notification via email and then use my program to generate the key and
send it via Email.
Well after finding out about PHP, and that my host does PHP, I thought it would
be quicker and more reliable to generate the keys on the server and send them
out again either vai email or from the sales site.
|
by: Keith Griffiths |
last post by:
I'm trying to do a search under a set criteria followed by a selection of
random entries meeting this criteria. But I don't seem to be able to
achieve this.
The idea being to search on say subject and then select a random set of
records meeting that subject.
Any ideas or thought would be helpful. I'm using Access XP to try this out.
TIA
|
by: Andie |
last post by:
Hello All,
How would I go about using a disconnect recordset and select (x) records
from it, x being the number of records to be selected.
Many thanks in advance.
--
Andie
|
by: Luke |
last post by:
Hello,
I am the administrator for http://www.nickberg.org - Nick is the man
who was recently beheaded in Iraq.
He was a very ingenious man - once for my birthday had gave me a small
box wrapped in duck tape with a few diodes and two wires sticking out.
When attaching the wires to your skin the diodes would light up in a
random configuration. (he later modified this into a skin resistance
|
by: Nhmiller |
last post by:
Is there a way to do this? Thanks.
Neil
Cat Paintings At Carol Wilson Gallery
http://www.carolwilsongallery.com
| |
by: yf |
last post by:
A KB article
"http://support.microsoft.com/default.aspx?scid=kb;en-us;209599" tells
that the maximum number of records that a table may hold if the PRIMARY
key data type is set to AUTONUMBER is 4,294,967,295.
Suppose the PRIMARY key data type is set to "RANDOM" AutoNumber.
Suppose an application
(a) successfully INSERTS "X" records, then
(b) successfully DELETES "Y" records (X >= Y), then
|
by: sugaray |
last post by:
I want to write a school computer billing system, one of the function
is to distribute machine id using rand() for each student log on,
suppose there's 100 machines, when each person log on, the system will
store user's info such as name, student id number, log on time, log
out time into a database file, when the next student log on, the
function loads the database, and compare the random generated machine
id with the existing ids store...
|
by: darrel |
last post by:
I can grab a random number in vb.net like this:
Dim RandomClass As New Random
Dim RandomNumber As Integer
RandomNumber = RandomClass.Next(1, 26)
However, what I want is a random number. Short of making a case statement
with 26 options, is there a more streamlined way to get an integer between
1-26 translated into one of the letters?
|
by: John Fairhurst |
last post by:
Hi,
The following code should select the specified number of records randomly
from the database
<%
....
query = "SELECT FROM "
Set RS = Server.CreateObject("ADODB.Recordset")
|
by: JuAn2226 |
last post by:
How do I create database which will store the random number that generated before I reset the random number and how do I check that new random number after I reset is exists in database. If exist then generate again and store new number in to database. I have created 10 label in the form which display the random number and at the same time I want random number generated to be stored in database. I don’t know how to start Plz help me with...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |