Solved

Failure to Detect vbMinimized

Posted on 2007-11-18
6
707 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
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 85

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 47

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

 
LVL 26

Assisted Solution

by:EDDYKT
EDDYKT earned 60 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 47

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 85

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

Industry Leaders: 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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…

680 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