Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to pass a control optionally

Reply
Thread Tools

How to pass a control optionally

 
 
eagle
Guest
Posts: n/a
 
      09-02-2005
How can I pass a control to another procedure as an option?

I tried:
Call DoStuff(lbl)

Private Sub DoStuff(Optional lnkbtn = nothing)

if lnkbtn <> nothing then lnkbtn.visible = true

end sub


and I get an error saying Operator is not valid for type LinkButton and
Nothing


 
Reply With Quote
 
 
 
 
Siva M
Guest
Posts: n/a
 
      09-02-2005
Hi,

Try DoStuff(Optional lnkbtn As Control = Nothing)

"eagle" <(E-Mail Removed)> wrote in message
news:%23E0Uan%(E-Mail Removed)...
How can I pass a control to another procedure as an option?

I tried:
Call DoStuff(lbl)

Private Sub DoStuff(Optional lnkbtn = nothing)

if lnkbtn <> nothing then lnkbtn.visible = true

end sub


and I get an error saying Operator is not valid for type LinkButton and
Nothing



 
Reply With Quote
 
 
 
 
Marina
Guest
Posts: n/a
 
      09-02-2005
1. Turn Option Strict On. Declare types for all your objects.
2. If Not IsNothing(lnkbtn) Then lnkbtn.Visible = True

"eagle" <(E-Mail Removed)> wrote in message
news:%23E0Uan%(E-Mail Removed)...
> How can I pass a control to another procedure as an option?
>
> I tried:
> Call DoStuff(lbl)
>
> Private Sub DoStuff(Optional lnkbtn = nothing)
>
> if lnkbtn <> nothing then lnkbtn.visible = true
>
> end sub
>
>
> and I get an error saying Operator is not valid for type LinkButton and
> Nothing
>



 
Reply With Quote
 
Karl Seguin
Guest
Posts: n/a
 
      09-02-2005
Or, use overloading

public sub DoStuff()
DoStuff(nothing)
end sub
public sub DoStuff(byval control as Control)
if not control is nothing then
control.Visible = true
end if
end sub

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)


"eagle" <(E-Mail Removed)> wrote in message
news:%23E0Uan%(E-Mail Removed)...
> How can I pass a control to another procedure as an option?
>
> I tried:
> Call DoStuff(lbl)
>
> Private Sub DoStuff(Optional lnkbtn = nothing)
>
> if lnkbtn <> nothing then lnkbtn.visible = true
>
> end sub
>
>
> and I get an error saying Operator is not valid for type LinkButton and
> Nothing
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How to acquire object's monitor optionally? Mark Space Java 3 09-30-2008 01:38 PM
Optionally pass a parameter? Peter Alvin Ruby 1 09-23-2008 11:57 AM
mandatory/optionally overridable virtual functions Dilip C++ 5 03-02-2007 09:30 PM
distutils: optionally build C bindings to an external library Kirill Simonov Python 2 10-09-2006 10:41 PM
How to optionally use classes that may or may not be installed ? Sam Iam Java 0 01-31-2004 04:09 AM



Advertisments