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

Vba

vba questions

Uploaded by

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

Vba

vba questions

Uploaded by

Rinny Wadhawan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Ivy Professional School

VBA Programming Questions

1
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
InputBox and MsgBox
• Enter two numbers and show the sum of two
numbers.

2
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• Enter a number and Evaluate if it is Even or
Odd.

3
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• Enter a Mobile Number and give the name of the
service provider based on the first 3 digits of
mobile number.

– AIRTEL - 990
– BSNL – 901
– MTS – 902
– Vodafone – 900
– Others – Rest of number

4
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
• Get 10 digit number (Inputbox)
• Check if it 10 digit (IF and LEN)
• Extract the three digits (LEFT)
• Compare the three digits against the list of SP
(ELSEIF)
• Display the SP (MSGBOX)

5
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• Enter the marks of a student and display the
grade based on the marks.

• >=90 : A
• 80 to 89 : B
• 70 to 79 : C
• 60 to 69 : D
• <60 : Fail

6
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• If a five digit number is entered through the
keyboard, write a program to calculate the sum
of digits.

• 34529
• Get 5 digit number
• Extract each digit
• Sum of digits

7
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• Write a program to reverse any three digit
number and after that check whether they are
equal or not.
• Hint : Strreverse

8
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• If three sides of a triangle are entered through
the keyboard. Write a program to check whether
the triangle is isosceles , equilateral or scalene
triangle.
• HINTS: If s1, s2,s3 are three sides of a triangle
then
– SCALENE S1<>S2<>S3
– ISOSCELES S1=S2, S2<>S3
– EQUILATERAL S1=S3=S2

9
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• Enter a number and check whether it’s a prime
number or not.

10
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• Write a program to find the greatest number out
of the three numbers entered through the
keyboard using IF.

11
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
• Write a program such that user can enter either
binary or decimal number
• If number entered in decimal then convert to Binary.
• If number entered in Binary then convert to Decimal

12
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
• Write a program that calculates a random number 1
through 100. The program then asks the user to
guess the number.
If the user guesses too high or too low then the
program should output "too high" or "too low"
accordingly.
The program must let the user continue to guess
until the user correctly guesses the number.

13
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• The wind chill index (WCI) is calculated from the
wind speed v in miles per hour and the
temperature t in Fahrenheit. Three formulas are
used, depending on the wind speed:
– if (0 <= v <= 4) then WCI = t
– if (v >=45) then WCI = 1.6t - 55
– otherwise, WCI = 91.4 + (91.4 - t)(0.0203v -
0.304(v)1/2 - 0.474).
• Write a program that can calculate the wind chill
index.
14
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• Find the numbers between 1 to 500 which
follow Armstrong rule below.
• HINTS: for example 153
coz. 1*1*1+5*5*5+3*3*3= 153

15
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• Calculate the factorial of any given number.
• HINTS: Factorial of 5= 5*4*3*2*!
Factorial of 6= 6*5*4*3*2*1

16
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• Write a program that can read three integers from the
user and then determines the smallest value among the
three integers.

17
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• Write a program to enter a text and calculate the number
of vowels, consonants and spaces.

• e.g.
Word is ‘Professional’
– Vowel = 5, consonants=7

18
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Program
• Write a program to
– Add two new workbooks
– Display the total number of workbooks
– Open any workbook from your desktop
– Activate the workbook in which you are working

19
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• Write a program such that you ask the user if a new
worksheet should be added to the workbook.

• If a new worksheet is added to the workbook then


change the name of the new worksheet to a user given
name.

20
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• Write a program such that you activate the sheet in the
workbook which the user wants.

21
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• Write a program such that you add two worksheets after
second sheet.

• Also, rename all the worksheets by appending your


initials after the basic name.

• Eg. Sheet1 will become Sheet1_EA


Sheet2 will become Sheet2_EA…

22
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• Create a User Defined Function which gives the Day
based on the date given.
• EXAMPLE: 3/24/2012 - Saturday

23
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
1. Create a User Defined Function to calculate the area of
a triangle using the Heron’s Formula-
e.g. Three sides of triangle – a,b,c
s=(a+b+c)/2
Area of Triangle = Square root of (s(s-a)(s-b)(s-c))

2. Through programming input three sides of a triangle and


check whether it is feasible triangle or not. If the triangle
is feasible calculate the area using the user defined
function.

24
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• Write a program that picks the students’ names and their
test scores from excel sheet and outputs the following
information:
– The average score
– Names of all students whose test scores are below
the average, with an appropriate message
– Highest test score and the name of all students
having the highest score

25
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• MyJava Café wants you to write a program to take orders from the
Internet. Your program asks for the item, its price, and if overnight
shipping is wanted. Regular shipping for items under $10 is $2.00;
for items $10 or more shipping is $3.00. For overnight delivery add
$5.00. For example, the output might be:
• Enter the item: Tuna Salad
• Enter the price: 4.50
• Overnight delivery (0==no, 1==yes): 1
• Invoice: Tuna Salad 4.50
• Shipping 8.00
• Total 12.50

26
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• Write the function which calculates the average of top n values in a
Range.

27
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Problem
• Write a procedure such that when you select a cell in a table,
corresponding row and column should gets shaded.

28
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)
Visit Ivy’s Blog for Career Tips, Latest Info, Job Alerts -
www.ivyproschool.com/blog
Interact with us at -

Ivy Professional School


14 B | Camac Street | Kolkata – 17
www.ivyproschool.com | [email protected]
T: 033 400 11221 | SMS: 9748 441111

29
Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

You might also like