Solved

Change form's text at runtime- not working!

Posted on 2011-09-03
15
265 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
  • 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 85

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
 

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 85

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 85

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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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 85

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 85

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 85

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now