Computer problems,Computer help
*AX SOFT>>>Programming & Design

VbScript - Help Me!?


How to determine the smallest number among three number and then determine whether the smallest number is either even or odd number. First, we ask user to enter 3 number(text Field), and then let them press enter button to proceed. Lastly, we show the message box for the result. I'm Using Notepad as an editor. Please Help me, i am a beginner in vbscript. :|

My Other Question: How to reply to the feedback we've got in here?

To Marco P. Your code is good but there is problem. The result not comes out as i want it to be. As an example when i entered 10,5,8 <- suppose the result is like this" number 5 is the smallest number and odd number". :)

hi,
use this coding:
<script language="vbscript">
dim n(2)
for i=0 to 2
n(i)=cint(inputbox("Enter 3 numbers"))
next

if n(0)<n(1) and n(0)<n(2) then
if n(0) mod 2 =0 then
Msgbox ("first number is smallest and Even number")
else
Msgbox ("first number is smallest and Odd number")
end if

elseif n(1)<n(0) and n(1)<n(2) then
if n(1) mod 2 =0 then
Msgbox ("second number is smallest and Even number")
else
Msgbox ("second number is smallest and Odd number")
end if

elseif n(2)<n(0) and n(2)<n(1) then
if n(2) mod 2 =0 then
Msgbox ("Third number is smallest and Even number")
else
Msgbox ("Third number is smallest and Odd number")
end if

end if
</script>

Surely you're not asking us to do your entire assignment for you, right? Let me give you some hints to get you over the two hardest parts.

Testing which is the least is simple:

if a < b and a < c then
' a is smallest
elseif b < a and b < c then
' b is smallest
elseif c < a and c < b then
' c is smallest
end if

There are other ways to do this but the above is pretty easy.

To see if a number is even, use the mod operator. mod returns the remainder when you divide the left number by the right number. So 9 mod 3 is 0 because 3 goes evenly into 9. You can test n for even/odd by doing n mod 2. If the result is 0, the number is even.

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • Can we move files accross a unix filesystem?explain ur answer .?

    Yes, you can move files across UNIX file systems - If you move files with in a file system, the same inode number is maintained and works more as a rename - When you move files across file syst...

  • Inheritance and polymorphism help pleaseeeeee!!!!!!!!!?

    I don't think this is an inheritance problem I think the problem is in your constructor definition. I can't tell for sure without seeing your code but you most-likely passing your para...

  • How do i change the text color of the letters inside a table (HTML)?

    Hi there, Add style to your <td> tag... <td style="color: #FF0000;"> Or you can put the text in between div tags... <td> <div style="color: #FF0000;...

  • Arrange the following in descending order?

    each letter represents 4 bits. So any number that begins with 8-F is negative You can convert the numbers like so hex binary 8 1000 9 1001 A 1010 B 1011 ...

  • Can <tr> rows be styled or do you have to style seperate <td> cells?

    Yes, table rows, can be styled, but you can;t just specify any type of style. Then again, this is true for all HTML elements. I know you can specify a background for a table row, but not a borde...

  • Autorun function?

    All you need to do is put an autorun.inf file in the root. Check the source. Note that autorun is a request, not a demand. Users may have their computer set up to disregard autoruns.

    ...
  • Here in Javascript version. Anyone can change it to vbscript?

    vbscript isn't really a good choice as it is server side while javascript is client side. You would need a big rework of this and turn it into a form. So you'd end up with a clunky for...

  • How do I make fractions on the?

    Go to insert, object (make sure create new) tab is clicked, then scroll down to microsoft equation. if it's not there, then u might have to install that part off of the cd

    ...
  •  

    Categories--Copyright/IP Policy--Contact Webmaster