Solved

Change form's text at runtime- not working!

Posted on 2011-09-03
15
269 Views
Last Modified: 2012-05-12
I'm using the code below to try and change the text of my form.

however, it's not working!

Suggestions?

Name of project is ScheduleMaster
Form is frmCalendar
In a module:
Public f2 As ScheduleMaster.FrmCalendar = New ScheduleMaster.FrmCalendar


In the form:
 f2.Text = gstrTitle & "IE instance created!"
        f2.Refresh()

Open in new window

0
Comment
Question by:scbdpm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
  • 2
15 Comments
 
LVL 6

Expert Comment

by:c1nmo
ID: 36477997
f2.Show()
0
 

Author Comment

by:scbdpm
ID: 36478000
but this is on the form itself.

0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 36478008
If you're in the form itself then use "Me":

    Me.Text = gstrTitle & "IE instance created!"
    Me.Refresh()

Why do you have "f2" setup like this in the first place?  If you describe your setup a bit more we may be able to help you better...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:scbdpm
ID: 36478022
sorry, correction

I have a few pieces of code that usse that same thing.

they are in modules....
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 36478025
Again...you need to describe your setup in more detail if you want help.

Most likely you are displaying a different instance of ScheduleMaster.FrmCalendar than the one you have referenced in the Module.

Can you show the code that initially displays ScheduleMaster.FrmCalendar?
0
 

Author Comment

by:scbdpm
ID: 36478047
this is the only form in my project.

0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 36478117
What version VB.Net are you working with?

I assume FrmCalendar is the "startup object" in Project Properties then?

What are you using the Module for?...
0
 
LVL 6

Expert Comment

by:c1nmo
ID: 36478262
Are you creating multiple new instances of FrmCalendar from FrmCalendar via a module function/sub?

In a module:
Public f2 As ScheduleMaster.FrmCalendar = New ScheduleMaster.FrmCalendar
f2.show()

In the form:
 me.Text = gstrTitle & "IE instance created!"

? is this in the load event or similar?
0
 

Author Comment

by:scbdpm
ID: 36481373
Idle_Mind- you are correct,
frmCalendar is the starup object.

basically this project opens an IE windows (this is done in the module) and then logs in to a website.

Since I don't really have any real estate on my form to put a listbox or label for status updates, my plan was to change the form text so the user can see the progress:

0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 36481388
"frmCalendar is the startup object"

Get rid of your "f2" variable.

In your module, just use the Name of the form:

    FrmCalendar.Text = gstrTitle & "IE instance created!"
0
 

Author Comment

by:scbdpm
ID: 36481394
Forgot one other item: VS 2003.

When I changed to frmcalendar.text, I get the following error:
"Reference to a non-shared member requires an object reference."

when I research that, I found the solution seemed to be the "f2...."

0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 250 total points
ID: 36481417
Ah...ok.  The approach I suggested will not work in VS2003.  It uses the "default instance" of the form and is available in VS2005 (and above).

In that case, you'll need to set the "f2" variable to reference YOUR instance of FrmCalendar.

In the Load() event of the form, set the "f2" variable like this:

    Private Sub FrmCalendar_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        f2 = Me
    End Sub
0
 

Author Comment

by:scbdpm
ID: 36481443
that did it!!!

thanks Idle_Mind

just becoming familiary with VB.Net (don't laugh- tranisitioning from VB6).

is VS 2005 a better choice than 2003?
how about 2010?
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 36481454
In my opinion, VS2003 --> VS2005 is a huge improvement in abilities and tools provided.  VS2008 added support for LINQ while VS2010 added new multi-threaded paradigms.

VS2005 should be the base standard these days.  Not many people are still using 2003!...

Take a look at the Visual Basic Application Model introduced in 2005:
http://msdn.microsoft.com/en-us/library/w3xx6ewx(VS.80).aspx
0
 

Author Comment

by:scbdpm
ID: 36485460
LOL!
"Not many people are still using 2003!..."

I'm still on VB6... Just now making the transition..l but I'm just a 'weekend' programmer and enjoy doing it!

Have an opportunity to upgrade to 2010 and will do so!
Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question