|
| |||||||||
| Tags: programming language, round a number, scripting language, software coding, vb script, vbscript programs |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Round a number in VB-Script
Hi to all. This is my query regarding VB-Script programs. I have few assignments to submit which are for VB-Script. Of which there are a few programs which I am unable to code. Especially the program to Round a Number using VB-Script. Also I want the code to get a random number returned or a random number within a specified range. I am unable to code the program to replace some characters in a string. Help me to code the above mentioned programs and especially as I have mentioned help me with the program to Round a Number using VB-Script. |
|
#2
| ||||
| ||||
| VBScript Program to round up a number
I also had hard time to code the program to round a number in VBScript programming. But then I learnt about the in-built function of VBScript known as the Round() function. This is the function used to round a number in VBScript. Here is a program using VBScript to round up a number: HTML Code: <html> <body> <script type="text/vbscript"> a = 37.273095 b = 14.82649 Round Up Value:document.write(Round(a)) Round Up Value:document.write("<br /><br/>") Round Up Value:document.write(Round(b)) </script> </body> </html> |
|
#3
| ||||
| ||||
| Random Numbers between 0 to 50
The following program will help you to generate Random number in the range of 0 -50. HTML Code: <html> <body> <script type="text/vbscript"> Randomize() temp=Int(50 * Rnd()) document.write("A random number: <b>" & temp & "</b>") </script> </body> </html> |
|
#4
| ||||
| ||||
| Rnd( ) to get Random numbers
To get a random number generated in VBScript we can make use of the Rnd(). This Rnd() function will provide you with pseudo-random number. This random number generated by Rnd() function is a value which is positive but cannot be greater the one. We can use this pseudo-random number and multiple with another value to get any pseudo-random number that is less then the provided value. |
|
#5
| |||
| |||
| Replacing String HTML Code: <Html> <Body> <Head> <Title>Replacing String</title> </Head> <Script type="text/vbscript"> strng="Replace this" document.write(Replace(strng, "Replace", "Swap")) </Script> </Body> </Html> |
|
#6
| ||||
| ||||
| Returning Random Number
I had an assignment that asked for a program in VBscript that would return a random number. Here is how I coded the program: HTML Code: <Html> <body> <script type="text/vbscript"> Randomize() Random Number document.write(Rnd()) </script> </body> </Html> |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Round a number in VB-Script" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Another round of waterblocks on i7 | Galimberti | Overclocking & Computer Modification | 5 | 01-09-2010 05:37 AM |
| Round up program for C# | Damien25 | Software Development | 4 | 22-01-2010 10:19 PM |
| Need help on ROUND function in excel | Cade | Windows Software | 5 | 26-12-2009 08:29 PM |
| Task duration time not a round number | katalinc | Microsoft Project | 6 | 02-03-2009 05:33 AM |
| Round Portable DVD Player | AdamT | Portable Devices | 0 | 12-07-2008 01:12 PM |