Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 03-11-2009
Member
 
Join Date: Nov 2009
Posts: 47
VBA Beginner questions

I am trying to get into VBA (for my profession). I read a few courses on it and I made a quiz for the first chapter but I do not have the fix, so I wanted to know if somebody who knew a lot could help me by telling me if my answers are good (if false plz give me the correct answer)

Question 1:

Which of the following is NOT an object declaration (Choose one answer.)
a. Dim x as Workbook
b. Dim x as Worksheet
c. Dim x as Integer
d. Dim x as Range
e. Dim x as Float
Reply With Quote
  #2  
Old 03-11-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: VBA Beginner questions

Answer 1.c.

To quickly see if an object or not, we can put a point behind x and see if a list of properties appears. Moreover, the publisher puts Integer blue. The words Float, Workbook, Worksheet, and Range are in black. I do not know whether an object is Float. I said it was a data type as Integer. But we must choose only one answer, and also when you hit F1, the help does nothing. But, if we write Double instead of Float, the help said that this type of data. So perhaps it's a trap and Float is neither an object nor a type of data, or it may depend on the versions of VBA.
Reply With Quote
  #3  
Old 03-11-2009
Member
 
Join Date: Nov 2009
Posts: 47
Re: VBA Beginner questions

Question 2
Marks: 1 A variable "MyVar" is defined in the declaration region of Module 2 as follows:

Dim MyVar as Double

Which of the following statements is most correct?

a. MyVar can be used in any procedure within any Module within the current workbook
b. MyVar can be used in any procedure within Module 1 but not Module 2
c. MyVar can be used in any procedure within Module 2 but not Module 1
d. MyVar can be used in any procedure within Module 2 and any module with a number higher than 2 in the current workbook

Question 3
Marks: 1 Consider the following expression:

switch(MyTest, MyVal1, True, MyVal2)

Which of the following remarks about it is True?

a. it is exactly equivalent to iif(MyTest = MyVal2, MyVal1, True)
b. it is exactly equivalent to iif(MyTest = MyVal1, MyVal2, True)
c. it is exactly equivalent to iif(MyTest, MyVal1, MyVal2)
d. it is exactly equivalent to iif(MyTest, MyVal2, MyVal1)
e. it is exactly equivalent to iif(MyTest = MyVal1, True, MyVal2)

Question 4
Marks: 1 The following lines of code are typed directly into the Immediate Window. What are the values of X and Y printed by the Print statements?

X = 10
Y = 25
' Swap Values
X = Y
Y = X
Print "X is " & X & ", and Y is " & Y


a. X is 10, and Y is 25
b. X is 25, and Y is 25
c. X is 25, and Y is 10
d. X is 10, and Y is 10
e. None of the above, there is a syntax error in the Debug.Print statement
Reply With Quote
  #4  
Old 03-11-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: VBA Beginner questions

For question 2, I can not remember his head if the default is Private or Public, but this should be easy to check with Excel.

For question 3, we must look at the doc function switch().

For question 4, the answer is 4B. Just take the test, or to imagine what is happening, or have the habit to manually swap in which case it always goes through an intermediate variable.
Reply With Quote
  #5  
Old 03-11-2009
Member
 
Join Date: Nov 2009
Posts: 47
Re: VBA Beginner questions

Question 5
Marks: 1 A variable MyVar is defined within a procedure called MyProc in a module called "Module 1".

Dim MyVar as Integer

Which of the following is most correct?

a. MyVar can be used within loops and branches within MyProc but nowhere else
b. MyVar can be used anywhere within Module 1, but not outside the module
c. MyVar can be used within the procedure MyProc but no where else
d. MyVar can be used within the spreadsheet, but no where else

Question 6
Marks: 1 What is the value printed by the following code fragment?

Sub test()

Dim i As Integer
i = 4.2 / 2
Debug.Print i

End Sub


a. Runtime Error
b. Syntax Error
c. 2.1
d. 2
e. 2.0

Question 7
Marks: 1 Which of the following statements is most correct?

a. Arrays are fixed sized arrays, and can be changed with a ReDim statement
b. Arrays are fixed sized arrays, and the size can be decreased with a ReDim statement, but not increased
c. Arrays are fixed size vectors and the size can never be changed
d. Arrays are fixed sized arrays, and the size can be increased with a ReDim statement, but not decreased
e. Arrays are fixed sized arrays, and can be changed with a ReDim statement as long as the dimensionality remains unchanged
Reply With Quote
  #6  
Old 03-11-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: VBA Beginner questions

Question 5 is a bit like Question 2

For question 6, the answer is 6D. It was not a very difficult question because the VBA behaves here as in almost all other languages. In addition, the VBA is known to many conversions implicitly, and to be quite liberal with the types of data used. The Runtime Error happens less frequently than other languages.

For question 7, I choose 7E, hesitating a little with 7A. In any case, it is not 7B. ReDim lose much of its interest if it could not expand a table.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "VBA Beginner questions"
Thread Thread Starter Forum Replies Last Post
Beginner in Platter Swap Kunal_R.One Hardware Peripherals 4 20-02-2012 12:37 PM
Beginner interview questions - MS Exchange mukutd Windows Server Help 1 28-05-2011 12:23 AM
How to Overclock Athlon II x3 445 (Beginner) aahisTA Motherboard Processor & RAM 4 19-12-2010 10:35 PM
C++ beginner need help about a program KALLIYAN Software Development 3 16-10-2009 06:56 PM
Beginner in JAVA need some help! VivekT Software Development 1 02-03-2009 05:45 PM


All times are GMT +5.5. The time now is 03:51 AM.