Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


help me!.. vbscript function or if statement

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,65078
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> help me!.. vbscript function or if statement
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 help me!.. vbscript function or if statement - 10/14/2008 3:50:59 PM   
  acc

 

Posts: 7
Score: 0
Joined: 9/25/2008
Status: offline
 
hi to all...
plzz help me.. i'm have a question like this..







Write a VBscript to determine the smallest of three numbers; and then determine
whether the smallest number is odd or even number. you are free to design
the input and output screen. An example of such screen as the below





enter number : 12

enter number : 6

enter number :35

output msgbox
 
6 is the smallest and is even




-------------------------------

this my code but not function...can u all help me modify the code

<HTML>
<head>
<script language="vbscript">
 

Sub cmdcalculate_onclick
Dim small
Dim no1
Dim no2
Dim no3

if no1 < no2 then
small = no1
else
if no2 < small then
small = no2
else
if no3 < small
small = no3

msgbox "Small number is" & small
msgbox "is even"
End sub

</script>
</head>

<body>
<form>
<p>
this program be create for determine  the smallest number and either even or odd. semalat mencuba!!!!!<br>
PLEASE KEEP IN FIRST NUMBER  :<INPUT TYPE="TEXT" NAME="no1" SIZE=5><br><br>
PLEASE KEEP IN second NUMBER :<INPUT TYPE="TEXT" NAME="no2" SIZE=5><br><br>
PLEASE KEEP IN third NUMBER  :<INPUT TYPE="TEXT" NAME="no3" SIZE=5><br><br>

<input type="button" name="cmdcalculate" value ="ENTER"><br><br>
</p>
</form>
</body>
</html>
 
 
Post #: 1
 
 RE: help me!.. vbscript function or if statement - 10/14/2008 4:15:24 PM   
  dm_4ever


Posts: 2669
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Start by fixing your If statements


If xxx Then

End If

If xxx Then

End If

If xxx Then

End If

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to acc)
 
 
Post #: 2
 
 RE: help me!.. vbscript function or if statement - 10/14/2008 4:31:46 PM   
  acc

 

Posts: 7
Score: 0
Joined: 9/25/2008
Status: offline
ooo.. if i use no is x<y,y<z and z<x
how about variable. what can i use.

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: help me!.. vbscript function or if statement - 10/15/2008 12:16:33 AM   
  dm_4ever


Posts: 2669
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Your comparisons can probably stay.  I'd start easy....first see if you can retrieve the values from your text box.  second, convert them to numbers using one of the built in function like CDbl, then continue with the comparison much like you originally had except make sure to write your If statements correctly.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to acc)
 
 
Post #: 4
 
 RE: help me!.. vbscript function or if statement - 10/15/2008 2:43:20 PM   
  acc

 

Posts: 7
Score: 0
Joined: 9/25/2008
Status: offline
 
hi guy..

yahoo.. my scripyt function but... can any body help me tu add 'reset button'

when i try create reset button the script not function

below is my script.. without reset button

-------------------------------------------------------------------------------
<HTML>
<HEAD>
   <TITLE> VBscript Example </TITLE>
<SCRIPT LANGUAGE="VBSCRIPT">
<!--
 
Option Explicit
  Function Find_smallest(v1,v2,v3)
  ' A simple function to be find the minimum of three numbers
    dim smallest
    smallest = v1
    if v2 < smallest then smallest = v2
    if v3 < smallest then smallest = v3
    Find_smallest = smallest   
  End Function
// menentukan ama ada ganjil atau genap
Function OddEven(smallest)
If smallest Mod 2 = 0 Then
Call MsgBox("Jadi, " & smallest & "  adalah nombor Genap" )    'memaparkan no genap
Else
Call MsgBox("Jadi, "& smallest & "  adalah nombor Ganjil" )   'memaparkan no ganjil
End If
End Function

  Sub cmdsmallest_onclick()                    'mencari no yang paling kecil
    Dim num1, num2, num3
    num1 = CInt(txtV1.Value)
    num2 = CInt(txtV2.Value)
    num3 = CInt(txtV3.Value)
    Dim smallest
       smallest = Find_smallest(num1,num2,num3)
 
    MsgBox("Nombor yang paling kecil adalah  " & smallest)
   
      Call OddEven(smallest)
  End Sub
-->
</SCRIPT>
</HEAD>
<body>
  
    First No         : <INPUT TYPE=TEXT NAME=txtV1>  <br>   
    Second No    : <INPUT TYPE=TEXT NAME=txtV2> <br>
    Third No        : <INPUT TYPE=TEXT NAME=txtV3> <br>

<p align=center>
  <INPUT TYPE=button Name=cmdsmallest VALUE="Press">
</p>
</body>
</HTML>

-------------------------------------------------------------------------------------------------------------------

(in reply to dm_4ever)
 
 
Post #: 5
 
 RE: help me!.. vbscript function or if statement - 10/16/2008 11:39:45 AM   
  acc

 

Posts: 7
Score: 0
Joined: 9/25/2008
Status: offline
anybody can help!!!!

(in reply to acc)
 
 
Post #: 6
 
 RE: help me!.. vbscript function or if statement - 10/16/2008 3:12:18 PM   
  dm_4ever


Posts: 2669
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
If reset for you is clearing the values then


      

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to acc)
 
 
Post #: 7
 
 RE: help me!.. vbscript function or if statement - 10/16/2008 7:22:54 PM   
  acc

 

Posts: 7
Score: 0
Joined: 9/25/2008
Status: offline
 
OOO... THAT MEAN WE MUST DICLARE VARIABLE BEFORE.....I NO DOING THAT ...


10Q    BRO....

so..administrator may off this script  so that there will not Plagiarism for student make their assigment ..

(in reply to dm_4ever)
 
 
Post #: 8
 
 RE: help me!.. vbscript function or if statement - 10/22/2008 3:33:15 PM   
  jbambli

 

Posts: 1
Score: 0
Joined: 10/22/2008
Status: offline
are you from OUM ????

(in reply to acc)
 
 
Post #: 9
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> help me!.. vbscript function or if statement Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts