By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,263 Members | 1,537 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,263 IT Pros & Developers. It's quick & easy.

Visual Basic beginner question

P: n/a
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

Sep 7 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
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

Sep 7 '06 #2

P: n/a
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.

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.

Sep 8 '06 #3

P: n/a

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
Sep 11 '06 #4

P: n/a
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

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

Sep 12 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.