‘**********************************************************************************************
‘VB SCRIPT PRACTICES - BASICS SET - 1
‘VB SCRIPT PRACTICES - BASICS SET - 1
‘**********************************************************************************************
‘**********************************************************************************************
'Sample 1: Print “WELCOME Message”
‘**********************************************************************************************
'Sample 1: Print “WELCOME Message”
Public Function funcWelcome()
MsgBox "WELCOME TO VB SCRIPT"
End Function
‘**********************************************************************************************
‘**********************************************************************************************
'Sample 2: Display sum of 2 numbers”
'Sample 2: Display sum of 2 numbers”
Public Function funcSum()
Dim intNo1, intNo2
intNo1 = 2
intNo2 = 3
Sum = intNo1 + intNo2
MsgBox "Sum of "& intNo1&", "& intNo2&" is "& Sum
End Function
‘**********************************************************************************************
‘**********************************************************************************************
'Sample 3: Finding an Applicant eligible for applying for job or not
'Sample 3: Finding an Applicant eligible for applying for job or not
Public Function funcFindEligibleForApplyForJob()
Dim intAge
intAge = InputBox("Enter age of the Applicant")
If intAge > 18 Then
MsgBox "You are eligible for applying Job"
End If
End Function‘**********************************************************************************************
‘**********************************************************************************************
'Sample 4: Find given number is even or odd
'Sample 4: Find given number is even or odd
Public Function funcFindEvenOrOdd()
Dim intNo
intNo = InputBox("Enter which number you have to find even or odd number")
If intNo Mod 2 = 0 Then
MsgBox "Given Number is "& intNo &" Even Number"
Else
MsgBox "Given Number is "& intNo &" Odd Number"
End If
End Function
‘**********************************************************************************************
‘**********************************************************************************************
'Sample 5: Verify for Given Year is Leap Year or not
'Sample 5: Verify for Given Year is Leap Year or not
Public Function funcLearYearOrNot()
Dim intYear
intYear = InputBox("Enter which Year you have to find Leap Year or NOT")
If intYear Mod 4 = 0 Then
MsgBox "Given Year is "& intYear &" Leap Year"
Else
MsgBox "Given Year is "& intYear &" NOT Leap Year"
End If
End Function
‘**********************************************************************************************
‘**********************************************************************************************
'Sample 6: Find Simple Interest for given Principle, Time and Rate
'Sample 6: Find Simple Interest for given Principle, Time and Rate
Public Function funcSimpleInterest()
Dim intPrinciple, intRate, intTime, intSimpleInterest
intPrinciple = InputBox("Enter Principle")
intRate = InputBox("Enter Rate")
intTime = InputBox("Enter Time in Months")
intSimpleInterest = (intPrinciple * intRate * intTime) / 100
MsgBox "Simple Interest for Principle :: "&intPrinciple&" :: Rate :: "&intRate&" :: Time ::"&intTime& " is ::: "&intSimpleInterest
End Function
‘**********************************************************************************************
‘**********************************************************************************************
'Sample 7: Find Compond Interest for given Principle, Time and Rate
'Sample 7: Find Compond Interest for given Principle, Time and Rate
Public Function funcCompoundInterest()
Dim intPrinciple,decRate,intTime,intNoOfTimesPerYear,intCompoundInterest
intPrinciple = InputBox("Enter Principle")
decRate = InputBox("Enter Rate in Decimal")
intTime = InputBox("Enter Time in Years")
intNoOfTimesPerYear = InputBox("Enter No. of Times per year")
intCompoundInterest = (intPrinciple*(1+decRate/intNoOfTimesPerYear))^( intTime*intNoOfTimesPerYear)
MsgBox "Compound Interest for Principle :: "&intPrinciple&" :: Rate :: "&intRate&" :: Time ::"&intTime& " :: No of Times per Year :: "&intNoOfTimesPerYear& " is ::: "&intCompoundInterest
End Function
‘**********************************************************************************************
‘**********************************************************************************************
'Sample 8: Find biggest of 3 numbers
'Sample 8: Find biggest of 3 numbers
Public Function funcBiggestOfThreeNumbers()
Dim intNo1, intNo2, intNo3
intNo1 = InputBox("Enter Number 1")
intNo2 = InputBox("Enter Number 2")
intNo3 = InputBox("Enter Number 2")
If intNo1 > intNo2 and intNo1 > intNo3 Then
MsgBox intNo1 &" is Big"
Else If intNo2 > intNo3 and intNo2 > intNo1 Then
MsgBox intNo2 &" is Big"
Else
MsgBox intNo3 &" is Big"
End If
End If
End Function
‘**********************************************************************************************
‘**********************************************************************************************
'Sample 9: Print “Even” numbers between the given range
'Sample 9: Print “Even” numbers between the given range
Public Function funcPrintEvenNumbers()
Dim intRange1, intRange2, intEven
intRange1 = InputBox("Give start number for Range")
intRange2 = InputBox("Give end number for Range")
For intI = intRange1 to intRange2
If intI Mod 2 = 0 Then
MsgBox "Even Number "& intI
End If
Next
End Function
‘**********************************************************************************************
‘**********************************************************************************************
'Sample 10: Print “Odd” numbers between the given range
'Sample 10: Print “Odd” numbers between the given range
Public Function funcPrintOddNumbers()
Dim intRange1, intRange2, intEven
intRange1 = InputBox("Give start number for Range")
intRange2 = InputBox("Give end number for Range")
For intI = intRange1 to intRange2
If intI Mod 2 <> 0 Then
MsgBox "Odd Number "& intI
End If
Next
End Function
‘**********************************************************************************************
‘**********************************************************************************************
'Sample 11: Print “Factorial” for given number
'Sample 11: Print “Factorial” for given number
Public Function funcPrintOddNumbers()
Dim intNo, intFact
intFact = 1
intNo = InputBox("Give your number for Factorial")
For intI = 1 to intNo
intFact = intFact * intI
Next
MstBox "Factorial Value for "&intNo&" is "& intFact
End Function
‘**********************************************************************************************
‘**********************************************************************************************
'Sample 12: Print Prime number up to given number
'Sample 12: Print Prime number up to given number
Public Function funcPrintPrimeNumbers()
Dim intPrimeNoLimit
intPrimeNoLimit = InputBox("Give start number for Range")
For intI=1 to intPrimeNoLimit
For IntJ=2 to round(intI/2)
If intI mod IntJ=0 Then
Exit for
End If
Next
If IntJ=round(intI/2)+1 or intI=1 Then
MsgBox "Prime No: "&intI
End If
Next
End Function
‘**********************************************************************************************
‘**********************************************************************************************
'Sample 13: Display Factor for given number
'Sample 13: Display Factor for given number
Public Function funcFactorForGivenNumber()
Dim intNo, intI
intNo = InputBox("Give number for which you want Factors")
For intI=1 to intNo/2
If intNo mod intI=0 Then
MsgBox "Factors for "&intNo&" are "&intI
End If
Next
End Function
‘**********************************************************************************************
‘**********************************************************************************************
'Sample 14: Display Length of Given String
'Sample 14: Display Length of Given String
Public Function funcLengthOfString()
Dim strString
strString = InputBox("Enter the String you want to find Length")
MsgBox "The Length of Given String "&strString&" Is "&Len(strString)
End Function
‘**********************************************************************************************
No comments:
Post a Comment