[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

If statement for calling modules

Posted on 2004-10-27
2
Medium Priority
?
158 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
Suggested Courses

656 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