0% found this document useful (0 votes)
37 views

Vbscript

This document contains code for several VBScript examples: 1) A simple if/else statement that checks if variable a is greater than b and displays a message. 2) An if statement that takes numeric user input and checks if it is even or odd. 3) An if statement that takes two user input values, calculates their sum, and displays the result. 4) A login validation form that checks user input against hardcoded values and displays success or failure messages. 5) Code that validates login form input, sets a cookie with the username on successful login, and displays a message.

Uploaded by

ShaikYusaf
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Vbscript

This document contains code for several VBScript examples: 1) A simple if/else statement that checks if variable a is greater than b and displays a message. 2) An if statement that takes numeric user input and checks if it is even or odd. 3) An if statement that takes two user input values, calculates their sum, and displays the result. 4) A login validation form that checks user input against hardcoded values and displays success or failure messages. 5) Code that validates login form input, sets a cookie with the username on successful login, and displays a message.

Uploaded by

ShaikYusaf
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Simple if: vNum1 = InputBox ("Enter First

Number","Windows Office 2007")


<html> If vNum1 = "" Then
<body> MsgBox ("You didn't enter anything!")
<script language="vbscript"> Else
Dim a vNum2 = InputBox ("Enter Second
a = 60 Number","Windows Office 2007")
Dim b : b = 40 vTotal = cint(vNum1)+cint(vNum2)
If a > b then MsgBox "You entered " & vNum1 & " and
document.write "a is Greater than b" " & vNum2 & " which totals " &
else vTotal,,"Well done!"
document.write "B is bigger" document.write("Sum of two
End If numbers:"&vTotal)
</script> End If
</body> </script>
</html> </body>
</html>
Simple if with build function
Client Side Script
<html>
<body> <html>
<script language="vbscript"> <head>
Dim num <title>Login form validation</title>
num=inputbox("Enter a number") <script language="vbscript">
sub validate()
if num mod 2=0 then
Dim a
msgbox "You entered an even
Dim b
number" a=document.f1.txtlogin.value
else b=document.f1.txtpw.value
msgbox "You entered an Odd if a="y" and b="u" then
number" msgbox "Login success"
end if else
</script> msgbox "Login Failed.....Try Again"
</body> end if
</html> end sub
</script>
</head>
IF statement with Msgbox and user <body>
input values <p align="center">
<h1>Login Form</h1>
<html> <br>
<body> <form name="f1">
<script language="vbscript"> Login Id<input type="text" name="txtlogin">
Dim vNum1,vNUm2,vTotal <br>
Password<input type="password"
name="txtpw">

1
<br> <input type="reset">
<input type="button" name="cmdlogin" </body>
value="login" onclick="validate()"> </html>
<input type="reset">
</body>
</html>

Creating and storing cookies:


<html>
<head>
<title>Login form validation</title>
<script language="vbscript">
sub validate()
Dim a,b
a=document.f1.txtlogin.value
b=document.f1.txtpw.value

If document.f1.txtlogin.value="" Then
msgbox "Enter some value!"
elseif a="y" and b="u" then
msgbox "Login success"

cookievalue=(document.f1.txtlogin.value)
document.cookie="name=" +
cookievalue
msgbox "Setting Cookies : " &
"name=" & cookievalue
else
msgbox "Login Failed.....Try
Again"
End If
end sub
</script>
</head>
<body>
<p align="center">
<h1>Login Form</h1>
<br>
<form name="f1">
Login Id<input type="text" name="txtlogin">
<br>
Password<input type="password"
name="txtpw">
<br>
<input type="button" name="cmdlogin"
value="login" onclick="validate()">

You might also like