Results 1 to 6 of 6

Thread: 'if' question{resolved}

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2003
    Location
    england
    Posts
    161

    'if' question{resolved}

    I want my code so that if no tabstrip is selected the caption of the form is blank, or just 'StarSurfer v1.1 'or whatever. The code i have so far is:

    VB Code:
    1. Me.Caption = WebBrowser1(TabStrip1.SelectedItem.Tag).LocationName & "  StarSurfer v1.1"
    2.         End If

    this doesnt work if no tab is selected, i get an error.

    I've tried this code:

    VB Code:
    1. If TabStrip1.SelectedItem = Nothing Then
    2.         Me.Caption = "Starsurfer v1.1"
    3.         Else
    4.         Me.Caption = WebBrowser1(TabStrip1.SelectedItem.Tag).LocationName & "  StarSurfer v1.1"
    5.         End If

    but i get the error "invalid use of object"

    anyone know what i should do??
    Last edited by shaunyboy; Dec 1st, 2003 at 01:43 PM.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106
    I haven't worked with this particular situation, but perhaps an error isn't a bad thing. If the first code works unless nothing is selected, in which case you get an error, why not just trap that error? Your error handler would look for the particular error raised if nothing is selected, clear the label, and Resume Next.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2003
    Location
    england
    Posts
    161
    yes i know, but if i use on error resume next the caption stays the same as the old website, not making the program look professional.

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106
    Can't you clear the label in the error handler before the Resume Next statement?

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    When dealing with objects....you can't test to see if something equals nothing.....
    but what you can do is see if something IS nothing.....
    VB Code:
    1. If TabStrip1.SelectedItem [b][COLOR=red]IS[/color][/b] Nothing Then
    2. .
    3. .
    4. .


    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Oct 2003
    Location
    england
    Posts
    161
    thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width