Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 276
  • Last Modified:

Change form's text at runtime- not working!

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
scbdpm
Asked:
scbdpm
  • 7
  • 6
  • 2
1 Solution
 
c1nmoCommented:
f2.Show()
0
 
scbdpmAuthor Commented:
but this is on the form itself.

0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
scbdpmAuthor Commented:
sorry, correction

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

they are in modules....
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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
 
scbdpmAuthor Commented:
this is the only form in my project.

0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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
 
c1nmoCommented:
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
 
scbdpmAuthor Commented:
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
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
"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
 
scbdpmAuthor Commented:
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
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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
 
scbdpmAuthor Commented:
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
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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
 
scbdpmAuthor Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 7
  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now