Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2021 connectés 

  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  Quizz debutant VBA

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Quizz debutant VBA

n°1937302
JC86
Posté le 03-11-2009 à 15:55:38  profilanswer
 

Bonjour a tous,  
 
Je suis en train de me lancer dans VBA (j'en ai besoin dans un cadre professionnel en finance...). J'ai lu quelques cours dessus et j'ai fait un quizz pour le premier chapitre mais dont je ne dispose pas de la correction, donc je voulais savoir si qn qui s'y connaissait bien pouvait m'aider en me disant si mes réponses sont les bonnes (si c'est faux pliz me donner la bonne réponse)
 
Merci d'avance pour votre aide,
 
Cordialement,
 
JC,
 
 
le test se trouve ci-dessous, mes réponses sont les suivantes : 1E / 2C / 3E / 4C / 5 A / 6A / 7B / 8E
 
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  
 
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?
 
Choose one answer. 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?
 
Choose one answer. 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
 
 
Choose one answer. 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  
 
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?
 
Choose one answer. 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
 
 
Choose one answer. 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?
Choose one answer. 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  
 
Question 8  
Marks: 1 Which of the following answers best describes the error in the following code fragment.
 
Dim x as Range
 
x = Range("A1" ).offset(0, 0)
 
 
 
Choose one answer. a. Range should be replaced by Application.ActiveSheeet.Range  
b. the variable x needs to be declared as an array  
c. It is illegal to access the 0th element of a range  
d. The assignment requires a set instead of a variable assignment  
e. Range should be replaced by Application.Sheets(0).Range

mood
Publicité
Posté le 03-11-2009 à 15:55:38  profilanswer
 

n°1937308
olivthill
Posté le 03-11-2009 à 16:15:17  profilanswer
 

Citation :

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  

1.C. Pour voir rapidement si c'est un objet ou non, on peut mettre un point derrière x et voir si une liste de propriétés apparait. D'ailleurs, l'éditeur met le Integer en bleu. Les mots Float, Workbook, Worksheet, et Range sont en noir. Je ne sais pas si Float est un objet. J'aurais dit que c'était un type de données comme Integer. Mais il ne faut choisir qu'une seule réponse, et par ailleurs, quand on tape F1, l'aide ne donne rien. Par contre si l'on écrit Double au lieu de Float, l'aide dit que c'est un type de données. Donc, peut-être que c'est un piège et que Float n'est ni un objet ni un type de données, ou bien cela dépend peut-être des versions de VBA.

Message cité 1 fois
Message édité par olivthill le 03-11-2009 à 16:22:21
n°1937314
JC86
Posté le 03-11-2009 à 16:45:29  profilanswer
 

Merci! As tu une idée pour les autres?

n°1937317
olivthill
Posté le 03-11-2009 à 16:57:20  profilanswer
 

J'avais envie de laisser les autres répondre, mais comme ils sont absents, allons-y.
 
Pour la question 2, je ne me souviens plus de tête si le comportement par défaut est Private ou Public, mais ce doit être facile à vérifier avec Excel.
 
Pour la question 3, il faut regarder la doc de la fonction switch().
 

Citation :

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  
 
 
Choose one answer. 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  
 

Pas de chance, la réponse est 4B, et non pas 4C. Il suffit de faire le test, ou d'imaginer ce qui se passe, ou d'avoir l'habitude faire des swaps manuellement auquel cas, on passe toujours par une variable intermédiaire.

n°1937320
olivthill
Posté le 03-11-2009 à 17:06:02  profilanswer
 

La question 5 ressemble un peu à la question 2

Citation :

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  
 
 
Choose one answer. a. Runtime Error  
b. Syntax Error  
c. 2.1  
d. 2  
e. 2.0  

Pas de chance encore, la réponse est 6D et non pas 6A. Ce n'était pas une question très difficile car le VBA se comporte ici comme dans la quasi totalité des autres languages. De plus le VBA est connu pour faire beaucoup de conversions de manière implicite, et donc d'être assez libéral avec les types de données utilisées. Le Runtime Error arrive plus rarement qu'avec d'autres langages.

n°1937323
olivthill
Posté le 03-11-2009 à 17:10:46  profilanswer
 

Citation :

Question 7  
Marks: 1 Which of the following statements is most correct?  
Choose one answer. 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  

Je choisirais 7E en hésitant un peu avec 7A. En tous cas, ce n'est pas 7B. ReDim perdrait beaucoup de son intérêt s'il ne pouvait pas étendre un tableau.

n°1941777
Laoo
Posté le 18-11-2009 à 09:01:30  profilanswer
 

olivthill a écrit :

Citation :

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  

1.C. Pour voir rapidement si c'est un objet ou non, on peut mettre un point derrière x et voir si une liste de propriétés apparait. D'ailleurs, l'éditeur met le Integer en bleu. Les mots Float, Workbook, Worksheet, et Range sont en noir. Je ne sais pas si Float est un objet. J'aurais dit que c'était un type de données comme Integer. Mais il ne faut choisir qu'une seule réponse, et par ailleurs, quand on tape F1, l'aide ne donne rien. Par contre si l'on écrit Double au lieu de Float, l'aide dit que c'est un type de données. Donc, peut-être que c'est un piège et que Float n'est ni un objet ni un type de données, ou bien cela dépend peut-être des versions de VBA.


 
 
 :pfff:  :pfff:  :pfff: Non!!
1 = e !
 
Toutes les autres propositions sont acceptables, SAUF la e, qui ne correspond à rien. Si tu tapes "Dim X as ", tu as ttes les propositions acceptables; la seule qui n'apparaisse pas est "Float".
Pour vérifier si un mot est un mot-clef, tu le tapes entièrement en minuscules, puis entrée. Si la première lettre devient une majuscule, ok *, sinon c'est raté. (*après, faut voir si c'est le bon...?)   :p


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  Quizz debutant VBA

 

Sujets relatifs
[VBA-E] Problème pour macro collage spécial[VBA] Passer d'une TextBox à une autre avec TAB
Debutant Struts2 - Eclipse for Java EE ou Lomboz ?Variable VBA dans une macro
[VBA] Plantage Excel avec Worksheet_ChangeVBA racine carrée comment faire ?
Variable VBA Vbscrip[debutant] sript pour renseigner un base putty .reg
VBA Stdev variable sharpe ratio[vba excel debutant] creer 1 programme en boucle
Plus de sujets relatifs à : Quizz debutant VBA


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR