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

x
?
Solved

Failure to Detect vbMinimized

Posted on 2007-11-18
6
Medium Priority
?
731 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 86

Accepted Solution

by:
Mike Tomlinson earned 195 total points
ID: 20308598
"...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 86

Expert Comment

by:Mike Tomlinson
ID: 20308601
* 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 49

Author Comment

by:Martin Liss
ID: 20308626
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 26

Assisted Solution

by:EDDYKT
EDDYKT earned 180 total points
ID: 20320360
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 49

Author Comment

by:Martin Liss
ID: 20320393
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 86

Expert Comment

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

Glad you found the problem!  =)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

926 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