Results 1 to 6 of 6

Thread: VBA Beginner questions

  1. #1
    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

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    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.

  3. #3
    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

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    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.

  5. #5
    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

  6. #6
    Join Date
    May 2008
    Posts
    2,012

    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.

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,047,998.64742 seconds with 16 queries