Re: Creating a form object from string name

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



Stephany and Tom,

Where is the showed method be better than something as?

Private function MyDialogShow(TheText)
dim myDialogForm as new MyDialogFormBase
MyDialogForm.TheText = TheText
return MyDialogFormBase.ShowDialog
End function

Or if it is about real forms just use the SortedList, with the string in the
key and the object in the value.

Seriously curious

Cor


"Stephany Young" <noone@localhost> schreef in bericht
news:eov1Vb1CHHA.3916@xxxxxxxxxxxxxxxxxxxxxxx
If I understand you correctly and your tutor is putting more emphasis on
the quality of the 'help' content than how it is implemented, then all I
can say is that I would be asking for my money back.

I appreciate that uasge of the Activator is probably outside or more
advanced than the remit of your course. You will note also that my
response was to add to Tom's response, rather than addressing your
original post.

My more recent post was is response to your supplementary question as to
whether it was better to use a single form or use a seperate form for each
help 'context'. My main point here was that if you polled 20 people on the
subject you would, most likely, get 20 different views, all of which are
valid. Again, you will note that I did say that, in my view, you were were
on the right track with reusability.

My other comments were meant to be a generalisation prompted by the number
of posts we see in here looking for the answers to homework assignments
and were not meant to be a criticism of you personally.


"MikeB" <MPBrede@xxxxxxxxx> wrote in message
news:1163881629.277575.228500@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Ouch. I wasn't intending to represent someone else's opinion as my own,
I was merely asking a group of people I think are more experienced than
myself if my current plan is better program-wise than my original plan
that I presented and that I got help with. If I wanted to use other
people's work, a previous copy of this project is doing the rounds, I
could have just taken a loook at that to see how it was solved
previously. I'm trying to learn here.

As for the teacher, I lost more point on pixellated images and bad
grammar than on anything else and there is no feedback on the type of
code that I write. I figured most of it out from the lecture and
working through the book and using the Visual Studio Help.

The Activator. thing was just over my head, hence I asked for help.
Even if I did ask for help, the solution I have now come up with is not
based on any help I've been given, I was just asking if it was good. I
prefer it because while I have the working code for the activator., I
don't really understand how it does what it does. If my own solution
wasn't good, I'd have to spend even more time trying to dig in deep
enough to understand how it actually works. With my courseload, time is
very scarce. I work part-time and have a full 12 hours of coursework.


Stephany Young wrote:
Now you're getting into the realm of 'how long is a piece of string?'.

There is no right or wrong answer and everybody will have their own
(valid)
opinion on the subject.

I note in you original post that this is for a school assignment. My
advice
to you is to address the requirements of the assignment of which you
have
previously only alluded to one aspect (the help button).

If your teacher/tutor is worth his/her salt, part of the marking process
will be to gauge how you have gone about the 'problem solving' aspect
and,
supplying someone else's opinion and/or solution and presenting it as
your
work is not what it's all about.

That said, I will say that, in my opinion, you are on the right track
with a
'reusable' concept.


"MikeB" <MPBrede@xxxxxxxxx> wrote in message
news:1163822183.032475.118350@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Thank you to all for your help. I used this to make it work:

Dim _f As Form =
DirectCast(Activator.CreateInstance(Type.GetType("TestHelp." &
strFrom),
Form)
_f.Show()

I think there was a ")" missing, but I figured it out. It works great.

However, that gave me an idea and I have now created a single form
with
a picturebox and a rich text box. Into these controls I load two
files,
each with the same name as the name of the form calling for help. That
works too. Since I already have to write all the help text and capture
the screen images, it seems simpler to forego the creation of the
multiple individual forms my original approach would entail. Comments?


Tom Shelton wrote:
Stephany Young wrote:
Right on the money Tom, and you're absolutely correct, one must
supply
the
fully qualified class name.

I've successfully used this technique and I've a couple of notes
that
might
be helpful.

I prefer to use the overloads of the Activator.CreateInstance
method
that
take a Type as the first parameter as those return Object's as
opposed
to
the other overloads which return ObjectHandle's. This means that
one
has to
call the Type.GetType method using the class name string to get it
to
work,
e.g.:

Actually, using the type overload is the way I usally do it. I had
forgotten that the other returns an ObjectHandle.

--
Tom Shelton






.



Relevant Pages