Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

If statement for calling modules

Posted on 2004-10-27
2
Medium Priority
?
159 Views
Last Modified: 2010-05-02
Greetings,

I have code that populates a listbox if there is more than one IE window that has "View" in the title. I am trying to expand on that code to make an if...then statement that will do these things:

If > 1 IE window with "View" in the title, populate listbox

If only one  IE window with "View" in the title, continue to Call fEnumWindows

If there are not any IE windows with "View" in the title, pop a msgbox indicating such.

The code below seems to perform all three actions and not correctly jump to the appropriate if...then.

Any help is appreciated.


Dim IE As New InternetExplorer
    Dim SH As New ShellWindows
    For Each IE In SH
        If InStr(1, IE.Document.Title, "View", vbTextCompare) > 1 Then
            MsgBox "Opening listbox"
            frmTicketNumberList.Show
        ElseIf InStr(1, IE.Document.Title, "View", vbTextCompare) = Null Then MsgBox "There are tickets displayed on the screen."
        Else
            MsgBox "Will now update the only open ticket"
            Call fEnumWindows
        End If
    Next
0
Comment
Question by:jkrech17
2 Comments
 
LVL 32

Accepted Solution

by:
Erick37 earned 2000 total points
ID: 12428016
You could keep count of the windows...

Dim count As Long

For Each IE In SH
    If InStr(1, IE.Document.Title, "View") Then
        'populate listbox
        'MsgBox "Opening listbox"
        'frmTicketNumberList.Show
        List1.AddItem IE.LocationName
        count = count + 1
    End If
Next

If count = 0 Then
    MsgBox "No windows with " & Chr(34) & "View" & Chr(34) & " in Title"
End If
0
 

Author Comment

by:jkrech17
ID: 12428209
Erick37,

Thanks for the help. I used the If count along with else if to get the results I needed.

0

Featured Post

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.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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…
Suggested Courses
Course of the Month15 days, 13 hours left to enroll

580 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