Home All Groups Group Topic Archive Search About

Visual Basic beginner question

Author
7 Sep 2006 7:57 PM
MikeB
I've been all over the net with this question, I hope I've finally
found a group where I can ask about Visual Basic 2005.

I'm at uni and we're working with Visual Basic 2005. I have some books,

- Programming Visual Basic by Balena (MS Press) and
- Visual Basic 2005 by Willis (WROX),
but they don't go into the forms design aspects and describing the
various controls at all. What bookscan I get that will cover that?

Also, I'm trying out visual inheritance and I'm running into a weird
problem.

I create a form in my class library and put a button on the form. I
then try to assign the click event to that button as follows:


Public Class frmBaseFormT


    Private Sub btnBCISLogo_Click(ByVal sender As System.Object, -
                                        ByVal e As System.EventArgs)  -

                                        Handles btnBCISLogo.Click
        Application.Exit()
    End Sub
End Class


When I try to build the class, I get the error

  name 'Application' is not defined.

If I do exactly the same in a regular library (not a class library), I
get no error.

Any pointers on what I'm doing wrong?

Thanks

Author
7 Sep 2006 9:41 PM
GhostInAK
Hello mikeb,

The best way to learn about the various controls is to pop them onto a form
and play with them.  That's part of the fun.

As for your lil problem..  You should NEVER, EVER try to shut down an application
from within a class library. That class lib could be used anywhere.. and
attempting to shut down the app can cause all kinds of bad stuff to happen.
Applications are inherently unhappy entities.. prone to suicide.. So we,
as programmers, need not encourage them.  The application should be the only
entity capable of purposefully terminating the application.

So your form, at most, should consider cleaning itsself up.. Me.Dispose.
By the way.. what's wrong with the close button on the titlebar?

-Boo

Show quoteHide quote
> I've been all over the net with this question, I hope I've finally
> found a group where I can ask about Visual Basic 2005.
>
> I'm at uni and we're working with Visual Basic 2005. I have some
> books,
>
> - Programming Visual Basic by Balena (MS Press) and
> - Visual Basic 2005 by Willis (WROX),
> but they don't go into the forms design aspects and describing the
> various controls at all. What bookscan I get that will cover that?
>
> Also, I'm trying out visual inheritance and I'm running into a weird
> problem.
>
> I create a form in my class library and put a button on the form. I
> then try to assign the click event to that button as follows:
>
> Public Class frmBaseFormT
>
> Private Sub btnBCISLogo_Click(ByVal sender As System.Object, -
> ByVal e As System.EventArgs)
> -
> Handles btnBCISLogo.Click
> Application.Exit()
> End Sub
> End Class
> When I try to build the class, I get the error
>
> name 'Application' is not defined.
>
> If I do exactly the same in a regular library (not a class library), I
> get no error.
>
> Any pointers on what I'm doing wrong?
>
> Thanks
>
Author
8 Sep 2006 1:10 PM
Chris Dunaway
GhostInAK wrote:
Show quoteHide quote
> Hello mikeb,
>
> The best way to learn about the various controls is to pop them onto a form
> and play with them.  That's part of the fun.
>
> As for your lil problem..  You should NEVER, EVER try to shut down an application
> from within a class library. That class lib could be used anywhere.. and
> attempting to shut down the app can cause all kinds of bad stuff to happen.
>  Applications are inherently unhappy entities.. prone to suicide.. So we,
> as programmers, need not encourage them.  The application should be the only
> entity capable of purposefully terminating the application.
>
> So your form, at most, should consider cleaning itsself up.. Me.Dispose.
>  By the way.. what's wrong with the close button on the titlebar?
>
> -Boo
>

To add to what Ghost wrote (which you should heed by the way), the
reason that you can't call Application.Exit() is becuase the
Application class is defined in the System.Windows.Forms namespace.
You must have a reference to it in your class libarary and possibly add
Imports System.Windows.Forms to the top of your code.

But as Ghost said, don't exit your app from a class library.
Author
11 Sep 2006 11:27 PM
MikeB
GhostInAK wrote:
> Hello mikeb,
>
> The best way to learn about the various controls is to pop them onto a form
> and play with them.  That's part of the fun.

I was looking for a control that would allow me to create hotspots in a
map. Putting every type of control on a form seem like a terribly slow
process to finding out how to do things.

>
> As for your lil problem..  You should NEVER, EVER try to shut down an application
> from within a class library. That class lib could be used anywhere.. and
> attempting to shut down the app can cause all kinds of bad stuff to happen.
>  Applications are inherently unhappy entities.. prone to suicide.. So we,
> as programmers, need not encourage them.  The application should be the only
> entity capable of purposefully terminating the application.
>
> So your form, at most, should consider cleaning itsself up.. Me.Dispose.
>  By the way.. what's wrong with the close button on the titlebar?

So our project for the semester is to write a kiosk application with
information and reservation options for a cruise. It should have no
title bar so it cannot be closed down by rascals. Instead it has to
have a "secret" clickable logo on all pages, that when clicked will
close down the application. Also, after testing it must be possible to
easily remove this control.

Since this code is exactly the same in the entire application, I didn't
see the harm in putting that clickable control on the master form. If I
had to hand-code the control on each and every form it is a lot of
redundancy and I'm sure I'll get marked down.

Show quoteHide quote
>
> -Boo
>
> > I've been all over the net with this question, I hope I've finally
> > found a group where I can ask about Visual Basic 2005.
> >
> > I'm at uni and we're working with Visual Basic 2005. I have some
> > books,
> >
> > - Programming Visual Basic by Balena (MS Press) and
> > - Visual Basic 2005 by Willis (WROX),
> > but they don't go into the forms design aspects and describing the
> > various controls at all. What bookscan I get that will cover that?
> >
> > Also, I'm trying out visual inheritance and I'm running into a weird
> > problem.
> >
> > I create a form in my class library and put a button on the form. I
> > then try to assign the click event to that button as follows:
> >
> > Public Class frmBaseFormT
> >
> > Private Sub btnBCISLogo_Click(ByVal sender As System.Object, -
> > ByVal e As System.EventArgs)
> > -
> > Handles btnBCISLogo.Click
> > Application.Exit()
> > End Sub
> > End Class
> > When I try to build the class, I get the error
> >
> > name 'Application' is not defined.
> >
> > If I do exactly the same in a regular library (not a class library), I
> > get no error.
> >
> > Any pointers on what I'm doing wrong?
> >
> > Thanks
> >
Author
12 Sep 2006 6:26 PM
GhostInAK
Hello mikeb,

The solution is simple then, and doesn't break guidelines for class libraries.

Have the application enable the titlebar on each form for testing.. then
in production mode (in response to something in the config file perhaps)
have the app disable all titlebars.

-Boo


Show quoteHide quote
> GhostInAK wrote:
>
>> Hello mikeb,
>>
>> The best way to learn about the various controls is to pop them onto
>> a form and play with them.  That's part of the fun.
>>
> I was looking for a control that would allow me to create hotspots in
> a map. Putting every type of control on a form seem like a terribly
> slow process to finding out how to do things.
>
>> As for your lil problem..  You should NEVER, EVER try to shut down an
>> application
>> from within a class library. That class lib could be used anywhere..
>> and
>> attempting to shut down the app can cause all kinds of bad stuff to
>> happen.
>> Applications are inherently unhappy entities.. prone to suicide.. So
>> we,
>> as programmers, need not encourage them.  The application should be
>> the only
>> entity capable of purposefully terminating the application.
>> So your form, at most, should consider cleaning itsself up..
>> Me.Dispose. By the way.. what's wrong with the close button on the
>> titlebar?
>>
> So our project for the semester is to write a kiosk application with
> information and reservation options for a cruise. It should have no
> title bar so it cannot be closed down by rascals. Instead it has to
> have a "secret" clickable logo on all pages, that when clicked will
> close down the application. Also, after testing it must be possible to
> easily remove this control.
>
> Since this code is exactly the same in the entire application, I
> didn't see the harm in putting that clickable control on the master
> form. If I had to hand-code the control on each and every form it is a
> lot of redundancy and I'm sure I'll get marked down.
>
>> -Boo
>>
>>> I've been all over the net with this question, I hope I've finally
>>> found a group where I can ask about Visual Basic 2005.
>>>
>>> I'm at uni and we're working with Visual Basic 2005. I have some
>>> books,
>>>
>>> - Programming Visual Basic by Balena (MS Press) and
>>> - Visual Basic 2005 by Willis (WROX),
>>> but they don't go into the forms design aspects and describing the
>>> various controls at all. What bookscan I get that will cover that?
>>> Also, I'm trying out visual inheritance and I'm running into a weird
>>> problem.
>>>
>>> I create a form in my class library and put a button on the form. I
>>> then try to assign the click event to that button as follows:
>>>
>>> Public Class frmBaseFormT
>>>
>>> Private Sub btnBCISLogo_Click(ByVal sender As System.Object, -
>>> ByVal e As System.EventArgs)
>>> -
>>> Handles btnBCISLogo.Click
>>> Application.Exit()
>>> End Sub
>>> End Class
>>> When I try to build the class, I get the error
>>> name 'Application' is not defined.
>>>
>>> If I do exactly the same in a regular library (not a class library),
>>> I get no error.
>>>
>>> Any pointers on what I'm doing wrong?
>>>
>>> Thanks
>>>