|
-
Dec 1st, 2003, 01:28 PM
#1
Thread Starter
Addicted Member
'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:
Me.Caption = WebBrowser1(TabStrip1.SelectedItem.Tag).LocationName & " StarSurfer v1.1"
End If
this doesnt work if no tab is selected, i get an error.
I've tried this code:
VB Code:
If TabStrip1.SelectedItem = Nothing Then
Me.Caption = "Starsurfer v1.1"
Else
Me.Caption = WebBrowser1(TabStrip1.SelectedItem.Tag).LocationName & " StarSurfer v1.1"
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.
-
Dec 1st, 2003, 01:36 PM
#2
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.
-
Dec 1st, 2003, 01:39 PM
#3
Thread Starter
Addicted Member
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.
-
Dec 1st, 2003, 01:40 PM
#4
Can't you clear the label in the error handler before the Resume Next statement?
-
Dec 1st, 2003, 01:41 PM
#5
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:
If TabStrip1.SelectedItem [b][COLOR=red]IS[/color][/b] Nothing Then
.
.
.
TG
-
Dec 1st, 2003, 01:42 PM
#6
Thread Starter
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|