VBScript Examples

Share Embed Donate


Short Description

VB Script general examples...

Description

For more Scripts & QTP Documents Visit: www.gcreddy.com

VBScript General Examples

www.gcreddy.com

For Software Testing Documents visit: ww.gcreddy.net

1

For more Scripts & QTP Documents Visit: www.gcreddy.com 1) Write a program for finding out whether the given year is a leap year or not? Dim xyear xyear=inputbox ("Enter Year") If xyear mod 4=0 Then msgbox "This is a Leap year" Else msgbox "This is NOT" End If  2) Write a program for finding out whether the given number is, Even number or Odd number? Dim num num=inputbox ("Enter a number") If num mod 2=0 Then msgbox "This is a Even Number" Else msgbox "This is a Odd Number" End If  3) Read two numbers and display the sum? Dim num1,num2, sum num1=inputbox ("Enter num1") num2=inputbox ("Enter num2") sum= Cdbl (num1) + Cdbl (num2) 'if we want add two strings conversion require msgbox ("Sum is " &sum) 4) Read P,T,R P,T,R values and Calculate the Simple Interest? Dim p,t, r, si p=inputbox ("Enter Principle") t=inputbox ("Enter Time") r=inputbox ("Enter Rate of Interest") si= (p*t*r)/100 ' p= principle amount, t=time in years, r= rate of interest msgbox ("Simple Interest is " &si) 5) Read Four digit number, calculate & display the sum of the number or display Error message if the number is not a four digit number? Dim num, sum num=inputbox ("Enter a Four digit number") If Len(num) = 4 Then Then sum=0 sum=sum+num sum=sum+num mod 10 num=num/10 num= left (num, 3)

For Software Testing Documents visit: ww.gcreddy.net

2

For more Scripts & QTP Documents Visit: www.gcreddy.com sum=sum+num sum=sum+num mod 10 num=num/10 num= left (num, 2) sum=sum+num sum=sum+num mod 10 num=num/10 num= left (num, 1) sum=sum+num sum=sum+num mod 10 msgbox ("Sum is " &sum) else msgbox "Number, you entered is not a 4 digit number" End If  6) Read any Four-digit number and display the number in reverse order? Dim num,rev num= inputbox("Enter a number") If len(num)=4 Then rev=rev*10 + num mod 10 num=num/10 num= left(num,3) rev=rev*10 + num mod 10 num=num/10 num= left(num,2) rev=rev*10 + num mod 10 num=num/10 num= left(num,1) rev=rev*10 + num mod 10 msgbox "Reverse Order of the number is "&rev Else msgbox "Number, you entered is not a 4 digit number" End If  7) Read 4 subjects marks; calculate the Total marks and grade? (a) If average marks Greater than or equal to 75, grade is Distinction b) If average marks Greater than or equal to 60 and less than 75 , then grade is First c) If average marks Greater than or equal to 50 and less than 60 , then grade is Second d) If average marks Greater than or equal to 40 and less than 50 , then grade is Third e) Minimum marks 35 for any subject, otherwise 'no grade fail') Dim e,m,p,c, tot e=inputbox ("Enter english Marks") m=inputbox ("Enter maths Marks") p=inputbox ("Enter physics Marks") c=inputbox ("Enter chemistry Marks")

For Software Testing Documents visit: ww.gcreddy.net

3

For more Scripts & QTP Documents Visit: www.gcreddy.com tot= cdbl(e) + cdbl(m) + cdbl(p) + cdbl(c) msgbox tot

If cdbl(e) >=35 and cdbl(m) >=35 and cdbl(p) >=35 and cdbl(c) >=35 and tot >=300 Then msgbox "Grade is Distinction" else If cdbl(e) >=35 and cdbl(m) cdbl(m) >=35 and cdbl(p) >=35 >=35 and cdbl(c) >=35 and tot >=240 and tot=35 and cdbl(m) >=35 and cdbl(p) >=35 and cdbl(c) >=35 and tot >=200 and tot=35 and cdbl(m) >=35 and cdbl(p) >=35 and cdbl(c) >=35 and tot >=160 and tot
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF