Re: CORRECTED TEST AND ANSWERS.
- From: "Dmitriy Antonov" <antonovdima@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 6 Dec 2005 22:39:46 -0500
"Richard Jalbert" <richmann@xxxxxxxxxxxx> wrote in message
news:43963a2a.25338187@xxxxxxxxxxxxxxxxxxxxxxxx
> On Mon, 05 Dec 2005 18:47:43 GMT, richmann@xxxxxxxxxxxx (Richard
> Jalbert) wrote:
>
> Thing promised, thing due.
>
> In a project, you have a class named c_myClass.
> Write code example to instantiate that class.
>
> ---ANSWER
> Dim anObject as New c_myClass
> or
> Dim anObject as c_myClass
> Set anObject = New c_myClass
> or
> Dim anObject as c_myClass
> Set anObject = CreateObject(<ProjectName>.c_myClass) (TX to Dmitriy
> Antonov)
I have to correct myself - you should replace <ProjectName> with more
appropriate <ApplicationName>
> What is version compatibility option useful for?
>
Again - there is no Version Compatibility option
> ---------------------------------------------------------------------
> A form is Unloaded specifically set to Nothing while one control on
> it is still referenced somewhere. What will happens?
>
> ---ANSWER
> The form will be reloaded the instant that control is actively
> referenced and will be loaded with default values instead of the
> last values it contained.
I would say that the answer is too "foggy" (and question too)
> Open "foo.txt" For Input As #1
> For n=1 to 5 step 1
> if (n mod 2) <> 0 then
> Write #1,Cstr(n),n
> else
> Write #1,Cstr(n*2),n*3
> endif
> Next n
> Close #1
>
> What bad VB coding practices appear in the above code.
>
> ---ANSWER
> Opening a file for Input (from file to computer)
> and attempting to Write (from computer to file) to itwill cause a
> crash.
What you explain as a bad programming practice is, in reality, a programming
error (which is definitely not the same).
Hard-coded file number instead of using FreeFile - is a bad practice, while
not always an error (if, for example, I know for sure that no other part of
application performs IO operations, when this proc is running, then it is
never an error, still being a bad practice)
endif -> must be end if (IDE would fix it)
Lack of indentations is a bad style too
> Create a different one-liner equivalent to this statement
>
> Value = IIf(Len(TextString) > 0, "'" & TextString & "'", "NULL")
>
> ---ANSWER
> Value = Format$(Len(TextString), Trim$(Left$(Join(Split(StrConv( _
> " " & TextString, vbUnicode), Chr$(0)), "\"), _
> 2 * Len(TextString) + 1)) & ";;\N\U\L\L")
Will you consider this as a good answer (notice it perfectly fits given
question):
Value = IIf(Len(TextString) <=0, "NULL", "'" & TextString & "'")
You can add additional condition of not using IIf function.
Just for fun - this is another variant:
vValue = Choose(Sgn(LenB(TextString)) + 1, "NULL", "'" & TextString & "'")
>
> ---------------------------------------------------------------------
> What is the difference in scope of a module-level variable declared as
> Public, Friend and Private.
>
> ---ANSWER
> Scope Availability
> Public Everywhere
> Use when you need to give access to the whole project,
> or expose the code to other projects.
>
> Friend In the declaring project
> Friend is required when building projects that expose an interface
> to other projects. Use Friend to keep other projects from accessing
> the code.
> This can only be used in classes, not modules.
>
> Private In the declaring class/module
> Use for implementation procedures, all data,
> and enum/user-defined type definitions required only inside the
> class/module.
>
There are a lot of additional nuances here.
E.g. Public variable/method, declared in module, accessible within project
but not visible from outside, while the same variable/method declared in
public class are accessible via instances of that class from any client of
that component (inside or outside of the project). There are other details
here
Dmitriy.
.
- Follow-Ups:
- Re: CORRECTED TEST AND ANSWERS.
- From: Richard Jalbert
- Re: CORRECTED TEST AND ANSWERS.
- References:
- Re: CORRECTED TEST AND ANSWERS.
- From: Richard Jalbert
- Re: CORRECTED TEST AND ANSWERS.
- Prev by Date: Re: Transparent Listboxes
- Next by Date: Re: Multiple timers
- Previous by thread: Re: CORRECTED TEST AND ANSWERS.
- Next by thread: Re: CORRECTED TEST AND ANSWERS.
- Index(es):
Relevant Pages
|