Solved

Failure to Detect vbMinimized

Posted on 2007-11-18
6
684 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 46

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

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

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

920 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

18 Experts available now in Live!

Get 1:1 Help Now