Re: CORRECTED TEST AND ANSWERS.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"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.


.



Relevant Pages

  • Re: CORRECTED TEST AND ANSWERS.
    ... >What you explain as a bad programming practice is, in reality, a programming ... >> What is the difference in scope of a module-level variable declared as ... >> Public, Friend and Private. ... >> Private In the declaring class/module ...
    (microsoft.public.vb.general.discussion)
  • Re: Error message about my user defined type
    ... > Declaring it as Friend does the trick, ... > function becomes a friend of everything else? ... COM servers (in VB or MS speak they are called ActiveX dlls or ActiveX ... Standard exes are not COM binaries. ...
    (microsoft.public.vb.general.discussion)
  • Re: C++ friend class equivalent
    ... Reflection is also less intrusive than declaring a ... If there was somthing equivalent to friend in C++ all i had to do ... You can do this with inheritance. ... protected int Increase ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: In memory row selection
    ... The highlighted line is an assignment to an Identifier named ... but it illustrates the application of a 'best practice' principle to code design. ... be made at the start of a function body. ... my own preference here is partly driven by the realisation that many of individuals who propose declaring variables at their first assignment are doing so precisely because they have the erroneous impression that javascript is block-scoped. ...
    (comp.lang.javascript)
  • Re: Template Friend Function
    ... > I'm having problems with declaring a template friend function. ...
    (comp.lang.cpp)