Solved

Failure to Detect vbMinimized

Posted on 2007-11-18
6
678 Views
Last Modified: 2012-06-21
I have a small program that's behaving very strangely. The problem code is something like this:

If Me.WindowState = vbMinimized Then
    lblResults.Caption = "long text"
Else
    Me.Caption = "short text"
End If

Pretty simple and as you might expect it works just fine on my PC and its Windows XP Professional SP2 OS. The problem is that when I install the app on my wife's PC which has Windows XP Multimedia Edition SP2 and run and minimize the app, the form's caption does not change to "short text" but rather remains at its default value.

I even went so far as to create my own IsMinimized property that depends on the form's Width and again while that works on my PC it doesn't on my wife's.

Does anyone have any idea what's going on?
0
Comment
Question by:Martin Liss
  • 3
  • 2
6 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 65 total points
Comment Utility
"...and run and minimize the app, the form's caption does not change to "short text" but rather remains at its default value."

Here is your code:

    If Me.WindowState = vbMinimized Then
        lblResults.Caption = "long text"
    Else
        Me.Caption = "short text"
    End If

In plain English, it translates to:
(1) If the WindowState IS Minimized, then change the "lblResults" Caption.
(2) If the WindowState is NOT Minimized then change the Forms Caption.

If you want "short text" in the Forms Caption when the Form is Minimized then you need:

    If Me.WindowState = vbMinimized Then
        Me.Caption = "short text"
    Else
        lblResults.Caption = "long text"
    End If
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
* Also, when the form is restored, you currently don't have any code in place to change the caption BACK to whatever it was before "short text".
0
 
LVL 45

Author Comment

by:Martin Liss
Comment Utility
After I posted the code I realized that what I wrote here was backward and should have been

If Me.WindowState = vbMinimized Then
    Me.Caption = "short text"
Else
    lblResults.Caption = "long text"
End If

And note that while this is just a mock up of the actual code, the actual code does work on my PC but not my wife's.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 26

Assisted Solution

by:EDDYKT
EDDYKT earned 60 total points
Comment Utility
where do you put on your routine?


Private Sub Form_Resize()
 

If Me.WindowState = vbMinimized Then

    Me.Caption = "long text"

    lblResults.Caption = ""

Else

    Me.Caption = ""

    lblResults.Caption = "short text"

End If
 

End Sub

Open in new window

0
 
LVL 45

Author Comment

by:Martin Liss
Comment Utility
I'm embarrased. I found the error and it had nothing to do with vbMinimized but rather an If statement that was blocking the changing of the caption.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
Lol...I'm pretty sure we've ALL done something similar at one point or another...  ;)

Glad you found the problem!  =)
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now