From: Larry Serflaten on

<bitshifter(a)sympatico.ca> wrote
> Subject: Ever had to judge a new to-be-hired in interview?
>
> This is a repost and is the result of a group effort by many, very
> many of you.
> I repost it because I reworked/corrected it and feel it should be
> given to the world.

Sorry Charlie. I saw at least two wrong answers and many that were
incomplete.

On the whole, I felt there were too many questions about Option Base
and arrays, when there are other questions that would likewise be good
indicators of general knowlege.

I'll just quote and reply to the wrong answers, there may be controversy
over what is or is not complete....

LFS



> ---------------------------------------------------------------------
> In a project, you have a class named c_myClass.
> Write code examples to instanciate that class.
>
> ---ANSWER
>
> Dim anObject as New c_myClass
>
> Dim anObject as c_myClass
> Set anObject = New c_myClass
>
> Dim anObject as c_myClass
> Set anObject = CreateObject(<ProjectName>.c_myClass)

The parameters to CreateObject are Strings, substituting the
project name would not work. In my quick test, CreateObject
would not create an instance of a VB class. (VB5)



> ---------------------------------------------------------------------
> What is wrong with this code?
>
> Dim n as long
> n = 5
> MyFunction(n)
> ...
> Private MyFunction(byval nVar as integer) as integer
> <Do something fun>
> End Function
>
> ---ANSWER
>
> n is a Long, the function calls for an Integer.
> It will work due to VB evil coercion but when the passed value
> exceeds the integer range (32,767 to -32,768), an error "Type
> mismatch" will occurs.
>
> Extra points:
> If the "byval" is absent from the function definition, then you get a
> compile error Byref type argument mismatch.


It would not work. The code would not compile, the keyword Function
is missing in the function declaration.



> ---------------------------------------------------------------------
> What will happen and why ?
>
> Dim anotherColl as Collection
> aColl(2)=25
>
> ---ANSWER
> Any of these is a valid answer:
>
> This code will produce run-time error on the line aColl(2)=25
>
> Run-time error '424' Object required
> Run-time error '438' Object doesn't support this property or method
>
> Members of Collection are read-only - you can remove or add them, but
> not assign the value...
>
> Extra points for these:
>
> Members of Collection are read-only - you can remove or add them, but
> not assign the value...UNLESS you address the exact property of an
> object being modified:
>
> Dim aColl As New Collection
> Dim anObj As oObj
> Dim i As Integer
> For i = 1 To 5 Step 1
> Set anObj = New oObj
> anObj.X = i
> aColl.Add anObj, CStr(i)
> Set anObj = Nothing
> Next i
> On Error Resume Next
> aColl(3).X = 25
> Debug.Print Err.Number & " " & Err.Description 'This works


The code produces a run-time error of 91. Neither of the two run-time
errors listed would be 'run-time' errors. They describe the conditions,
but would not be seen at 'run-time' due to error 91 being reported.




> ---------------------------------------------------------------------
> ProgressForm.Show vbModal
>
> For nCounter = 1 To 25 Step 1
> ProgressForm.Increment
> Next nCounter
>
> What's wrong with the above code ?
>
> ---ANSWER
>
> The ProgressForm object will not increment at all while it's visible,
> since it's opened with vbModal: code execution stops there until the
> user unload that form.
>
> And after closing the modal form it will be referenced by the
> subsequent
> code and everything will just hang there.

The code would not hang. The form would be shown modally,
dismissed, and then its Increment routine would be called 25 times.




> ---------------------------------------------------------------------
> Tell me about variable and functions naming conventions in VB.
>
> ---ANSWER
>
> There are none enforced by VB unless one uses TypeDef and then for
> that module only.
>
> Extra points for any of these:
> I use the Polish naming convention / simplified Polish naming
> convention / use self describing names / use name that tell what does
> what and returns what.


Variable and function names:
- Must begin with a letter
- Cannot contain an embedded period or type-declaration character
- Must not exceed 255 characters
- Must be unique with the same scope



From: Larry Serflaten on

<bitshifter(a)sympatico.ca> wrote
> Subject: Ever had to judge a new to-be-hired in interview?

Some questions that might help show proficiency...


- What does Option Explicit do?

- How are dates and times entered into, and stored, in a program?

- What does For Each do? Where and why would you use it?

- What are some of the differences between a module, a class, and a form?

- The VB IDE allows for the addition of References to a project. What are
references, and what are they used for?

- A class under development could have a public variable, or a public property.
How would you choose between the two?

- What are User Controls used for?

- Give an example (or two) of where an Enum might be used.

- What are some of the pros and cons to using a control array?

- You've created a class that is running amuck. What can you add to the
program to track when the class gets loaded into memory, and when it
gets removed from memory?

- Write a boolean function that will accept a string and report if the following
combinations are present in the string: "A1B1", "A2B1", "A1B2", "B1B2"

- List some of the tools the VB IDE provides to help debug a program.

- Your program often accepts short (less than 10) lists of item names. The
item names are entered in random order, but must be ouput in sorted order.
What are some of the methods you could use to produce the sorted lists?

- Most VB controls have Width and Height properties. Which controls have
ScaleWidth and ScaleHeight properties, and what are they used for?

- Under what conditions would you add code to the Form_Paint event?

- How many elements are there in an array declared: Dim A(5) As Byte

- What are the steps involved in reading data from a file. Include any
'defensive coding' steps you might include to avoid errors.

- When is it appropreate to use an Error Log?

- When is it appropreate to use a User Control?

And finally:

- Why do you want this job?

<g>
LFS



From: C. Kevin Provance on
Those were all too easy. Except for the last one of course. I got nothing.
<g>


"Larry Serflaten" <serflaten(a)usinternet.com> wrote in message
news:%2304e0gcrKHA.4284(a)TK2MSFTNGP04.phx.gbl...
|
| <bitshifter(a)sympatico.ca> wrote
| > Subject: Ever had to judge a new to-be-hired in interview?
|
| Some questions that might help show proficiency...
|
|
| - What does Option Explicit do?
|
| - How are dates and times entered into, and stored, in a program?
|
| - What does For Each do? Where and why would you use it?
|
| - What are some of the differences between a module, a class, and a form?
|
| - The VB IDE allows for the addition of References to a project. What are
| references, and what are they used for?
|
| - A class under development could have a public variable, or a public
property.
| How would you choose between the two?
|
| - What are User Controls used for?
|
| - Give an example (or two) of where an Enum might be used.
|
| - What are some of the pros and cons to using a control array?
|
| - You've created a class that is running amuck. What can you add to the
| program to track when the class gets loaded into memory, and when it
| gets removed from memory?
|
| - Write a boolean function that will accept a string and report if the
following
| combinations are present in the string: "A1B1", "A2B1", "A1B2", "B1B2"
|
| - List some of the tools the VB IDE provides to help debug a program.
|
| - Your program often accepts short (less than 10) lists of item names.
The
| item names are entered in random order, but must be ouput in sorted
order.
| What are some of the methods you could use to produce the sorted lists?
|
| - Most VB controls have Width and Height properties. Which controls have
| ScaleWidth and ScaleHeight properties, and what are they used for?
|
| - Under what conditions would you add code to the Form_Paint event?
|
| - How many elements are there in an array declared: Dim A(5) As Byte
|
| - What are the steps involved in reading data from a file. Include any
| 'defensive coding' steps you might include to avoid errors.
|
| - When is it appropreate to use an Error Log?
|
| - When is it appropreate to use a User Control?
|
| And finally:
|
| - Why do you want this job?
|
| <g>
| LFS
|
|
|


From: Larry Serflaten on

"Larry Serflaten" <serflaten(a)usinternet.com> wrote

> > ---------------------------------------------------------------------
> > What will happen and why ?
> >
> > Dim anotherColl as Collection
> > aColl(2)=25

> The code produces a run-time error of 91. Neither of the two run-time
> errors listed would be 'run-time' errors. They describe the conditions,
> but would not be seen at 'run-time' due to error 91 being reported.


Even my post had an error! I did not catch the two variables being
different names. As such, the code above (as written) will not even
compile....

Doh!
LFS


From: bitshifter on
On Sun, 14 Feb 2010 17:26:34 -0600, "Larry Serflaten"
<serflaten(a)usinternet.com> wrote:


>"Larry Serflaten" <serflaten(a)usinternet.com> wrote
>
>> > ---------------------------------------------------------------------
>> > What will happen and why ?
>> >
>> > Dim anotherColl as Collection
>> > aColl(2)=25
>
>> The code produces a run-time error of 91. Neither of the two run-time
>> errors listed would be 'run-time' errors. They describe the conditions,
>> but would not be seen at 'run-time' due to error 91 being reported.

Doh!...neither did I. It was supposed to be the same variable.

>Even my post had an error! I did not catch the two variables being
>different names. As such, the code above (as written) will not even
>compile....
>
>Doh!

....goes to show.

Thanks for the feedback.