473,549 Members | 2,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Rnd Command

Hi,

I have just been putting together a random number
generator to practice with VB .NET. The Rnd command on its
own works fine, however as soon as I add = 10 to the
string I get a return value of false. If i use the string
CStr(Int(Rnd() = 10)) I get a return value of 0.

What am I doing wrong - because the debugger seems to
think everything is fine.

Kind regards

Vicky
Nov 20 '05 #1
5 2524
you are doing a boolean comparison

rnd() could be 5.3
is 5.3 = 10 ? --> false
cint(false) = 0
cstr(0) = "0"

i don't know w you want w the = 10 but thats not the way to do it

hope it helps

eric

"V Power" <an*******@disc ussions.microso ft.com> wrote in message
news:20******** *************** *****@phx.gbl.. .
Hi,

I have just been putting together a random number
generator to practice with VB .NET. The Rnd command on its
own works fine, however as soon as I add = 10 to the
string I get a return value of false. If i use the string
CStr(Int(Rnd() = 10)) I get a return value of 0.

What am I doing wrong - because the debugger seems to
think everything is fine.

Kind regards

Vicky

Nov 20 '05 #2
Hi,

Well apprently that string was supposed to round the random
number to = say 7 rather than 0.708

CStr(Int(Rnd() = 10))

Hope that makes sense,

thanks for your answer Ive noted it :)

Vicky
-----Original Message-----
you are doing a boolean comparison

rnd() could be 5.3
is 5.3 = 10 ? --> false
cint(false) = 0
cstr(0) = "0"

i don't know w you want w the = 10 but thats not the way to do it
hope it helps

eric

"V Power" <an*******@disc ussions.microso ft.com> wrote in messagenews:20******* *************** ******@phx.gbl. ..
Hi,

I have just been putting together a random number
generator to practice with VB .NET. The Rnd command on its
own works fine, however as soon as I add = 10 to the
string I get a return value of false. If i use the string
CStr(Int(Rnd() = 10)) I get a return value of 0.

What am I doing wrong - because the debugger seems to
think everything is fine.

Kind regards

Vicky

.

Nov 20 '05 #3
that would be CStr(Int(Rnd() * 10)) :)
"V Power" <an*******@disc ussions.microso ft.com> wrote in message
news:21******** *************** *****@phx.gbl.. .
Hi,

Well apprently that string was supposed to round the random
number to = say 7 rather than 0.708

CStr(Int(Rnd() = 10))

Hope that makes sense,

thanks for your answer Ive noted it :)

Vicky
-----Original Message-----
you are doing a boolean comparison

rnd() could be 5.3
is 5.3 = 10 ? --> false
cint(false) = 0
cstr(0) = "0"

i don't know w you want w the = 10 but thats not the way

to do it

hope it helps

eric

"V Power" <an*******@disc ussions.microso ft.com> wrote in

message
news:20******* *************** ******@phx.gbl. ..
Hi,

I have just been putting together a random number
generator to practice with VB .NET. The Rnd command on its
own works fine, however as soon as I add = 10 to the
string I get a return value of false. If i use the string
CStr(Int(Rnd() = 10)) I get a return value of 0.

What am I doing wrong - because the debugger seems to
think everything is fine.

Kind regards

Vicky

.

Nov 20 '05 #4
Yeah,
Ive just sat and re-read it all loads and suddenly my
vision celared :)
I wont be forgetting that in a hurry! :)

thankyou

Vicky
-----Original Message-----
that would be CStr(Int(Rnd() * 10)) :)
"V Power" <an*******@disc ussions.microso ft.com> wrote in messagenews:21******* *************** ******@phx.gbl. ..
Hi,

Well apprently that string was supposed to round the random
number to = say 7 rather than 0.708

CStr(Int(Rnd() = 10))

Hope that makes sense,

thanks for your answer Ive noted it :)

Vicky
>-----Original Message-----
>you are doing a boolean comparison
>
>rnd() could be 5.3
>is 5.3 = 10 ? --> false
>cint(false) = 0
>cstr(0) = "0"
>
>i don't know w you want w the = 10 but thats not the way

to do it
>
>hope it helps
>
>eric
>
>"V Power" <an*******@disc ussions.microso ft.com> wrote in

message
>news:20******* *************** ******@phx.gbl. ..
>> Hi,
>>
>> I have just been putting together a random number
>> generator to practice with VB .NET. The Rnd command on its >> own works fine, however as soon as I add = 10 to the
>> string I get a return value of false. If i use the string
>> CStr(Int(Rnd() = 10)) I get a return value of 0.
>>
>> What am I doing wrong - because the debugger seems to
>> think everything is fine.
>>
>> Kind regards
>>
>> Vicky
>
>
>.
>

.

Nov 20 '05 #5
On Wed, 21 Apr 2004 02:47:58 -0700, V Power wrote:
Hi,

I have just been putting together a random number
generator to practice with VB .NET. The Rnd command on its
own works fine, however as soon as I add = 10 to the

Any reason you're not using the Random class?

'Create an instance of the random class
Dim rand As New Random(Environm ent.TickCount)

'Generate 10 random integers between 1 and 100
For x As Integer = 0 To 99
Console.WriteLi ne(rand.Next(1, 101).ToString)
Next

'Generate 10 random doubles between 0 and 1
For x As Integer = 0 To 99
Console.WriteLi ne(rand.NextDou ble.ToString)
Next

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2539
by: TEK | last post by:
Hello I'm wondering if anyone out there might give some input/suggestions/viewpoints around the Command pattern. In my case, the number one priority for using the pattern is undo support. Some now, a lot more in the future. I think I have a pretty good understanding about how the command pattern is tought to work, however during...
8
1333
by: Siemel Naran | last post by:
Hi. I'm writing a command shell that reads commands from standard input. At this point I have the command in a std::string. Now I want to execute this command in the shell. From the Borland newsgroups I learned that there is a function in stdlib.h called system. int system(const char *command); First question, is the system command...
2
9272
by: Chris Bolus | last post by:
I'm a teacher using MS Access on an RMConnect 2.4 network. On some workstations both I and my students sometimes get an error message when attempting to insert a command button on a form which reads "Invalid use of null". The remainder of the options in the Command Button Wizard are then unavailable and the button wil not work. The only...
2
6664
by: micahstrasser | last post by:
I have been trying for days to send a command to the command prompt through the shell() function in vb.net. For some reason it is not working. Here is the code: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim command As String command = "systeminfo > C:\temp\sysinfo.txt"
34
6825
by: Roman Mashak | last post by:
Hello, All! I'm implementing simple CLI (flat model, no tree-style menu etc.). Command line looks like this: <command> <param1> <param2> ... <paramN> (where N=1..4) And idea is pretty simple: 1) get whole string of input line 2) preset table of strings matching <command> 3) preset table of function calls
13
4475
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple command set consisting of several single letter commands which take no arguments. A few additional single letter commands take arguments:
0
1690
by: czerwww | last post by:
Can someone please help me? I have class for database connection and I need set command.commandTimeout. How can I do that? Code: Imports System.Data.SqlClient Imports System.Data Public Class Db Private Shared _ConnString As String = "" Private Shared _Connection As SqlConnection Public Shared Sub SetConnectionString(ByVal...
3
18684
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however, working with complex reports is tricky Assumption: Reader of this article have basic knowledge of creating data reports. Creating a Parent-Child...
51
4090
by: Ojas | last post by:
Hi!, I just out of curiosity want to know how top detect the client side application under which the script is getting run. I mean to ask the how to know whether the script is running under Command Prompt or Browser or some other application? Ojas.
0
7715
Oralloy
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. ...
1
7469
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...
0
7808
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6040
agi2029
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...
0
5087
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3498
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...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1935
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
1
1057
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.