Solved

Change form's text at runtime- not working!

Posted on 2011-09-03
15
266 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

26 Experts available now in Live!

Get 1:1 Help Now