Title Bar property help request

  • Thread starter Thread starter Vgolfmaster
  • Start date Start date
V

Vgolfmaster

Hi,

in visual basic, I'm trying to use a button click event to change the text
in the title bar. It is set to load defined text at form load, but I wish to
have a click event change it from the form load text, to custom text assigned
to the click event for a button. I can not find anywhere to access the title
bar text within the click event handler, any suggestions?
 
Already answered in microsoft.public.vb.general.discussion.

Please try not to cross-post also, and remember to direct your posts to the
correct newsgroup (otherwise some of the local primates can get quite nasty
:-) )
 
Set the form's text property to the text you want to display:

Form1.Text = "Form Title Bar Text"
 
Alex said:
Already answered in microsoft.public.vb.general.discussion.

Please try not to cross-post also, and remember to direct your posts to the
correct newsgroup (otherwise some of the local primates can get quite nasty
:-) )

If it was asked in the vb6 group, you should answer it in that context,
and answer it in the vb.net context here. Otherwise, some of us may
start to believe _you_ are actually Mike/Kevin.

To the OP, James has answered...
 
Alex Clark said:
Already answered in microsoft.public.vb.general.discussion.

After more than two hours after the OP said he would repost in the correct
group after was being told nicely to post to the correct newsgroup. Alex's
answer in the VB Classic newsgroup came two hours after the OP reposted to
the correct group.
Please try not to cross-post also

He didn't cross post or multipost. He followed usenet etiquette.
 
I answered it in both contexts there. And just to keep them happy, I even
put the VB6 answer first.

And of course, ol' Kevin/Mike loved it...
 
Sorry if this is the incorrect arena for this, but I was directed here from
the forum I incorrectly posted to the first time. If this is no the correct
forum, please link to to the right one, and I'll happily make the move.

The form load text I have set already, what I am looking for is a way to use
a click event to change the titlebar text. ie. create a 'calculate' button,
and after it does its math thingy, change the title bar text too.

V
 
James,

In the click event for the button I want to make this change, there is no
option for this.

The form itself is named 'frmBuying'

When I attempt to code this, and type 'Me.f'

the only form related objects that are available are:

FormBorderStyle
frmBuying_DoubleClick
frmBuying_Load

I also cannot simply type 'frmBuying.text = "text"' as I get an error.

If I try 'Me.frmBuying.text = "text"' I also get an error:

'frmBuying' is not a member of 'Buying_A_Gaming_Computer_Project.frmBuying'.


Don't know what to try next.
 
1 more follow up please....

just for kicks, I simply entered 'Me.text = "new text" under the button
click event, and it worked! I just don't know why.....

Being under the button click event, shouldn't that have changed the text of
the button? Or does it default to the form property/object unless you code it
elsewhere? I was assuming I had to instantiate the forms title bar object to
access the text, but obviously this was an incorrect assumption. It at least
appears that in a click event for button1 that:

me.text refers to the form
me.button1.text refers to the buttons text

I would have thought the exact opposite, and obviously that is where I was
wrong! I assumed that

me.text would apply to the buttons text -and-
me.frmBuying.text was needed to access the forms

Live and learn, I guess!

V
 
Vgolfmaster said:
James,

In the click event for the button I want to make this change, there is no
option for this.

The form itself is named 'frmBuying'

When I attempt to code this, and type 'Me.f'

Type 'Me.t' if you want to write Me.Text = ....
 
Sorry if this is the incorrect arena for this, but I was
directed here from the forum I incorrectly posted
to the first time. If this is no the correct forum,
please link to to the right one . . .

Why don't you just tell us whether you are using the real Visual Basic (the
last and final version of which was VB6) or a version of VB.Net, to which
Micro$oft have given a multitude of deliberately confusing names and which
is something completely different. Then you'll be directed to the
appropriate group, where you will be given the appropriate answer.

Mike
 
Visual Studio 2005 Professional, which under the 'product details' shows
Visual Basic 2005

You can consider this closed, as I got the correct result, and now just have
to teach myself how, lol
 
Vgolfmaster said:
1 more follow up please....

just for kicks, I simply entered 'Me.text = "new text" under the button
click event, and it worked! I just don't know why.....

Being under the button click event, shouldn't that have changed the text of
the button? Or does it default to the form property/object unless you code it
elsewhere? I was assuming I had to instantiate the forms title bar object to
access the text, but obviously this was an incorrect assumption. It at least
appears that in a click event for button1 that:

me.text refers to the form
me.button1.text refers to the buttons text

I would have thought the exact opposite, and obviously that is where I was
wrong! I assumed that

me.text would apply to the buttons text -and-
me.frmBuying.text was needed to access the forms

Live and learn, I guess!

V

'Me' points to an instance of the class that contains 'Me'. So, if it's
inside Class frmBuying, Me points to an instance of class frmBuying.

If Button1 is a field (a variable at class level, i.e. outside all
procedures), you refer to it by writing "Me.Button1".

'Me' is (usually) optional because the compiler resolves names inside
out, i.e. first it looks at the local variables and arguments, then at
class level. So, writing
Text="new text"
is the same as
Me.Text="new text"

and
Button1.text="new text"
is equal to
Me.Button1.text="new text"


One excpetion where you do need 'Me':

class MyForm
Inherits Form

sub MySum()

dim Text as string

text = "local" 'Changes local variable
me.text = "class level" 'Changes Form property
end sub

end class
 
Hi,

No, the "Me" always refers to the object instance your code is executing
inside of. In this context, that's your form, so anywhere inside an
instance method in your form class that you use "Me", you're referring to
the instance of that form.

HTH,
Alex
 
Instead of 'Me.frmBuying.text = "text"' use 'frmBuying.text = "text"' (the
use of 'frmBuying is exactly equivalent to my use of 'Form1' in my example).
 
Back
Top