Visual Basic

Testing

We feel that testing a candidate in a number of different ways is vital. Here are some of the things we do at TMS.

Telephone testing

As we've mentioned, whenever we're interested in recruiting an individual we'll arrange to phone them at home to discuss the position further. At the same time, we'll take the opportunity to probe their technical skills and generally attempt to gauge their personality and how they motivate themselves. As much as possible, we'll effectively conduct an interview with them right then and there. The idea behind this quick phone interview is to optimize the screening process and to save time-both theirs and ours. If you suspect the candidate is less than honest about his or her abilities, you can verify this quickly by asking one or two leading questions about some general development issue or about some appropriate technology. Like any company, we get a few "fakers" applying for jobs; some might be guilty of nothing more than creative writing, whereas others might be trying to deliberately land a job for which they're simply not qualified (figuring that they'll learn the skills on the job and at your expense). Telephone testing is inexpensive and a good way to start the relationship between the prospective employer and prospective employee. We recommend that you always take the time to do this prior to conducting the in-person interview.

Technical testing

At TMS, every potential developer we interview is also technically evaluated at a recruitment day. Mostly we use a paper-based written exam, which lasts more than two hours (the Visual Basic 6 exam currently contains 45 questions). The test is conducted under examination conditions, which means it's completed in a quiet, supervised room. Those who pass the test and eventually join TMS usually refer to the test as "the test from hell." To pass this test is to feel like you're joining an elite club. Make sure you tell the candidate that there will be a test before they come for the interview!

Introduction and About the Test

This test paper, once completed, summarizes our understanding of your technical comprehension of Windows' programming using Visual Basic and additionally provides us with a good indication of how you:

  • Work under pressure and to strict deadlines
  • Go about solving complex problems
  • Improvise and form educated guesses
  • And most importantly, think

No one is expected to deliver a perfect test paper at the end of two-and-a-half-hours (indeed, the design of the question paper and the time limit conspire to prevent this from happening), and candidates with various levels of expertise are of equal interest to us. Given this, and the fact that your completed test paper may be referred to during one of your interviews, it is essential to make an impression during the test. We repeat, however, that it is not necessary for you to know the answer to every question, or be a Visual Basic guru, to do well.

Tips on how to answer

It is vitally important to understand and answer the question (and to do it as fully, yet at the same time, as both space and time are limited, as economically as possible). Additionally, it is vital to be verbose and fully suspicious of the questions. Read the wording of each question carefully and try to ascertain what the questioner is after. Always assume that each question is a loaded question, potentially harder than it might at first appear. Once you've written your answer, reread it. Is the answer you gave ambiguous or clear? If you were marking this paper objectively, how would you score the answer on a scale of 1 to 10?

The testing room, and therefore the candidate(s), are "computer-free," so they don't have access to Visual Basic or to any help file text, nor do we provide any manuals. We're not really interested in whether someone can remember the number and order of the parameters to MsgBox, for example. That kind of stuff most people look up anyway. No, we're interested in how someone codes and generally solves problems. To give you an idea about what the test aims to find out, here is the title page from our test:

Exam technique

Although we want you to answer the questions in sequence and not jump about, it is always a good idea to read through the entire question paper before attempting to answer any individual question (10 minutes have been allowed for this). Often, something referred to in a later question helps in the answering of an earlier one-reading the question paper first therefore often has real advantages. This paper contains 44 questions and you have two-and-a-half hours (plus 10 minutes pre-reading time) to answer as many questions as you can. This gives you on average just over three-and-a-half minutes per question and answer (for all 44).

How we mark the paper

Each question is awarded around 10 points (some are higher, some lower). A total of 440 is the highest possible score. As your paper is being marked two scores are produced. One score is simply based on how many marks you scored out of 440 (an unanswered question scores 0). The other score is calculated on the actual questions you answered. That is, it indicates how well you did on the questions that you answered (unanswered questions are therefore ignored).

And finally

Once again, remember that this is not just a technical assessment-we're looking to see how you perform here in more general terms. After all, detail can be easily found in manuals and in help files! Now, get a fresh cup of coffee, breath deeply, make a real effort to relax, and tell yourself to enjoy the test.

After the test, maintain your own industry average and your own preferred score, the percentage that you would expect someone in your company to attain. Derive this score by having your current employees take the test. (Be sure that they didn't help write the test!) Log their scores and define your passing score.

The technical test we have works well for us and we always advise potential employers to evaluate candidates with something similar, whether they're looking to hire contractors or permanent members of the staff. Even an oral test might be sufficient, just so long as it's not too easy. Remember, you're looking to recruit great developers, so, while you might ask someone to explain what Option Explicit is all about, you'll probably want to probe a bit deeper as well. Here are some examples drawn from our current exam to give you a feel for the level of probing and what we think works. The answers are shown in Appendix B in case you want to test your own skills.

The TMS Exam

Q1. Given the following code fragment, what will be output by the Debug.Print statement? Explain your reasoning

  Dim a As Integer, b As Integer, c As Integer
  b = &HFFFF
  c = True
  a = b = c
  Debug.Print a, b, c

Q2. Assuming that lstResults is a standard Visual Basic list box control, what is the meaning of the following code fragments?

A.  Debug.Print lstResults.List(3)
  B.  For i = 0 to lstResults.ListCount - 1
      .
      .
      .
      Next i
  C.  If lstResults.ListIndex = -1 Then
      .
      .
      .
      End If
  D.  For i = 0 To lstResults.ListIndex - 1
          lstResults.ItemData(i) = i
      Next i

Q3. Write the function sNumToBin. This function is passed an integer and returns a string (assume 16 bits in the integer). The string contains the binary equivalent of the passed integral value. For example, if the function were passed 42 it would return the string "0000000000101010," and if it were passed -1 it would return "1111111111111111."

Q4. Write the function itoh. This function is passed a value and returns a string. The string contains the hexadecimal character equivalent of the passed integral value. For example, if the function were passed 14 it would return the string "E," and if it were passed -1 it would return an out-of-range indicator.

Q5. State how you would position a Visual Basic form (as it is loaded and before it becomes visible) in the center of the Windows desktop. Should the form appear centered irrespective of the screen resolution used?

Q6. State what descriptive, "Hungarian" prefix you would place before the following identifiers (there is no right or wrong answer to this question):

Identifier Type Scope Answer
BM010 Form Form
FileOpen Menu -
RecordCount Integer Global
FirstName String Array Modular
VehclNum Long Local
Vehicles Combo Box -
Time Label -

Q7. Part 1: Provide a full explanation of the following code fragment. Part 2: What, if anything, would change if we simply passed a constant instead of passing x both times? Part 3: Would changing the line SomeSub(X) to Call SomeSub(X) affect anything? Part 4: Would using ByVal cause a change? Part 5: State why Visual Basic employs a pass by reference parameter passing mechanism instead of a scheme based on pass by value.

Private Function SomeFunc(n As Integer) As Integer
      n = n + 1
  End Function
  Private Sub SomeSub(n As Integer)
      n = n + 1
  End Sub
  Private Sub cmdTest_Click()
      Dim X     As Integer
      Dim Dummy As Integer
      X = 1
      SomeSub (X)
      Debug.Print X
      X = 1
      Dummy = SomeFunc(X)
      Debug.Print X
  End Sub

Q8. Part 1: Write a small Form_Load event handler to multiply instantiate and suitably position a CommandButton control called cmdDigit to form a kind of calculator keypad. (Label the controls with digits, 0-9.). Assume that at design time a single cmdDigit control exists and that its Index property is set to 0 and its Caption is "0." Part 2: Write a cmdDigit_Click event handler to display any selected digit in the caption of a label control called labDisplay.

Q9. State as many ways as you can to search a source string for some substring in a case-insensitive way (so that the strings "Tms" and "TMS" match, for example).

Q10. Write the function NTrim$. This function is similar to the ?Trim$ functions (where ? is nothing, L, or R) already present in Visual Basic, except that it removes any NULL character in a string. A NULL character is a character whose ASCII value is 0.

Q11. Write the function bFileExists. This function has a single string parameter and returns either True or False. The function determines whether a file, the fully qualified name of which is given by the string parameter, actually exists or not.

Q12. Part 1: An item of data declared Public in a class can be treated as a property of the class. Additionally, properties can be defined using property procedures. Explain the differences between the two. Part 2: Which elements can be "exported" (made visible) from a class?

Q13. What events will the following code fragments cause to be invoked on Form1? In code fragment C, how many instances of Form1 exist once the code is executed?

Code Fragment A

Sub main()
      Dim fp As Form
      Set fp = Form1
  End Sub

Code Fragment B

Sub main()
      Dim fp As Form
      Set fp = New Form1
  End Sub

Code Fragment C

Sub main()
      Dim fp As Form
      Set fp = New Form1
      Load fp
  End Sub

Q14. A project consists of two forms, Form1 and Form2; a module, Module1; and a class, Class1. Form1 is the start-up form and Form2 contains a single button called Command1. Each item in this project (except for Form2) has the following in its general declarations section:

Public n As Integer

Additionally, in Module1, o is declared as Public o As Class1.

Form1

Private Sub Form_Load()
      Form1.n = 10
      Set o = New Class1
      o.n = 20
      Module1.n = 30
      Form2.Show
  End Sub

Form2

Private Sub Command1_Click()
      Debug.Print n
      Debug.Print Form1.n
      Debug.Print Module1.n
      Debug.Print o.n
  End Sub

Is the code above legal? Negate any illegalities you see in the code (if any) and state what is output to the debug window.

Q15. Write some code to give an example of all the following:

  • Optional arguments
  • Parameter arrays
  • Collections

Q16. What was VBCP (as shipped with Visual Basic versions 4 and 5) and how was it used?

Q17. What does this code do?

Form

Private Sub cmdTest_Click()
      Dim o As Class1
      Set o = New Class1
      Set o.Self = o
      Print TypeName(o.Self)
  End Sub

Class

Private This As Class1
  Public Property Get Self() As Class1
      Set Self = This
  End Property
  Public Property Set Self(o As Class1)
      Set This = o
  End Property

Q18. Part 1: Given the precedence rules detailed just below (taken from the Visual Basic Help Files), add parentheses to the following code showing clearly how it will be evaluated in Visual Basic. Part 2: What does the code print?

Dim n As Integer
  n = True And &HFF + True And &HFF00 + Not Not True = Not False Or &HFF
  + Not True Or &HFF00
  Print n

When several operations occur in an expression, each part is evaluated and resolved in a predetermined order called operator precedence.

When expressions contain operators from more than one category, arithmetic operators are evaluated first, comparison operators are evaluated next, and logical operators are evaluated last. Comparison operators all have equal precedence; that is, they are evaluated in the left-to-right order in which they appear. Arithmetic and logical operators are evaluated in the following order of precedence:

Arithmetic Comparison Logical
Exponentiation (^) Equality (=) Not
Negation (-) Inequality (<>) And
Multiplication and division (*, /) Less than (<) Or
Integer division (\) Greater than (>) Xor
Modulus arithmetic (Mod) Less than or equal to (<=) Eqv
Addition and subtraction (+, -) Greater than or equal to (>=) Imp
String concatenation (&) Like

Is

When multiplication and division occur together in an expression, each operation is evaluated as it occurs from left to right. When addition and subtraction occur together in an expression, each operation is evaluated in order of appearance from left to right. Parentheses can be used to override the order of precedence and to force some parts of an expression to be evaluated before others. Operations within parentheses are always performed before those outside. Within parentheses, however, operator precedence is maintained.

Q19. Where would you normally use a GoTo statement?

As an alternative to the written test (and if you have the resources) you could instead have the candidate write a Visual Basic application in the allotted two-and-a-half hours. Simply set the goal, give the candidate a fully-loaded machine, and then see what they come up with. While this has certain advantages, it also requires more subjective scoring of the applications, and therefore it's harder to compare apples with apples.
Find the answers here.

Psychometric testing

These days (even with the skills shortage) any potential TMS recruit could be forgiven for feeling like they're under the microscope. They're likely to have submitted a detailed rsum, been grilled over the phone and will have probably attended two interviews, and, of course, taken a technical test! In addition to assessing someone technically at interview time, we also assess the probability that they will fit in with the company culture. For both their sake and ours, anyone that we feel won't fit in with the way we work simply won't be hired. It makes sense that if a developer is a great technician but perhaps also a total soloist, then, sad as it might be to not have their skills in the company, we won't make an offer. In order to help us ascertain these qualities, we sometimes include some form of psychological profiling, usually in the form of a psychometric test.

A psychometric test is a selection tool used by an ever-increasing number of (typically) graduate employers to reduce their shortlist. Tests usually cover areas such as numerical and verbal reasoning; they're not just "psychobabble." In a nutshell, a psychometric test is a standardized sample of behavior that can be described using a numerical or categorical scale. The tests have an advantage over all other forms of assessment in that they are highly standardized. In other words, the test is the same for everyone who takes it. Therefore, all candidates are observed under identical conditions and their performance is measured objectively against a known and common standard. Also, the methods of interpreting the test results are standard and, once again, objective. There should be no room for error.

The bottom line is that the aim of the test is to match a prospective new employee with both the advertised position and, to a lesser extent, the corporate culture of the prospective employer. For example, if three already successful developers were tested within a team, and a pattern emerged that identified each of them as a highly dominant and extrovert individual, it is unlikely that another developer who is subservient or introverted would fit easily into that same team-or even, for that matter, become a great developer.

Remember to use psychometric tests selectively, and don't become too reliant on them or treat the results as gospel. Mix the tests with the other forms of assessment we've mentioned. Psychometric tests confirm your recruitment decision and support your assessment of each candidate to date. The tests should not be used as the decision-making tool. Unfortunately, many inexperienced interviewers fall into this trap.

As part of your overall recruitment process, you should also decide whether you plan to let each candidate have a copy of the results. Some companies do, some don't. It's human nature that most candidates will want to see their results, and many of the psychometric tests around at the moment will allow you to release selected parts of the results.