Solved

Change form's text at runtime- not working!

Posted on 2011-09-03
15
267 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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

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
 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

772 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