borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Read-Write USB Port [C#, CompactFramework])Next Topic (HIding the time, volume control, etc.) New Topic New Poll Post Reply
AndreaVB Forum : Pocket PC : eVB on PPC 2003
Poster Message
pkburr02
Level: Trainee

Registered: 16-08-2006
Posts: 1

icon eVB on PPC 2003

Ok i'm not an expert, closer to a beginner really i guess.  BUT I do know how to create a random number roller, and I've done so on my PDA it works fine EXCEPT i can't get it to generate a number without a decimal, i don't mean everyone once in a while i'll get one without a decimal i mean EVERY number it generates has one.  I thought (from quickbasic days) there was a way to get it to keep this from happening in short this is what i'm using:

Option Explicit
Dim roll As Integer

Private Sub cmdTest_Click()
Randomize
    roll = ((6 + 1) * Rnd)
    lblRoll.Caption = roll
End Sub

What am I missing?  Thanks in advance.

16-08-2006 at 07:45 PM
View Profile Send Email to User Show All Posts | Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 891
icon Re: eVB on PPC 2003

Hi Rnd returns a number between 0 and 1, so to remove the decimal you can multiply it by 10.
To get a rnd between a range of figures use the following:


Int((upperbound - lowerbound + 1) * Rnd + lowerbound)


Hope this helps,
Kieron

____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)

27-08-2006 at 10:16 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Pocket PC : eVB on PPC 2003
Previous Topic (Read-Write USB Port [C#, CompactFramework])Next Topic (HIding the time, volume control, etc.) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder