473,473 Members | 1,807 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to pass a control optionally

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
Nov 19 '05 #1
3 970
Hi,

Try DoStuff(Optional lnkbtn As Control = Nothing)

"eagle" <ea***@yahoo.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
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

Nov 19 '05 #2
1. Turn Option Strict On. Declare types for all your objects.
2. If Not IsNothing(lnkbtn) Then lnkbtn.Visible = True

"eagle" <ea***@yahoo.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
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

Nov 19 '05 #3
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" <ea***@yahoo.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
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

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert | last post by:
Python doesn't know the class of a method when container not direct class attribute: >>> class X: .... def f():pass .... g=f .... l= .... >>> X.g <unbound method X.f>
8
by: none | last post by:
Hi, I wrote a program for work that processed and formatted some collected text data in a Tkinter based GUI display. I've found that as my data files get longer (a few thousand lines), there...
1
by: Oleg Ogurok | last post by:
Hi all, In my page class, I'm loading a user control: private void Page_Load(object sender, System.EventArgs e) { Control c = LoadControl("WebUserControl1.ascx"); Controls.AddAt(0, c); }
2
by: Klaus Jensen | last post by:
Hi! I need an ASP.net control, which makes it possible for the user to define imagemaps. I show an image, the user can define areas (polygons would be nice, but just rectangles is ok), and I...
2
by: James Lavery | last post by:
Hi everyone, We're developing an application to capture data from several serial ports, store in a database, and (optionally) forward on using FTP. Each serial port is being processed in a...
1
by: LCAdeveloper | last post by:
Can anyone help me with this? I'm trying to get an MDIChild form to lookup the value of a control on another open MDIChild form, but can't seem to get the right syntax. Let's say the two child...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
1
by: shantanu_kush | last post by:
Hi there, I am using a DataList in a composite control. The DataList has an Custom ItemTemplate(ITemplate) which adds a Button to the DataList Item as shown in the code below : public class...
0
by: clintonG | last post by:
OBJECTIVE: A Wizard control often needs two TextBoxes on specific steps. In this instance both Step5 and Step6 each require two TextBoxes in each step, that is, each step requires a TextBox to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.