Solved

VB.NET Windows App - Optional Sub Parameter byRef Object default no reference

Posted on 2004-09-09
3
424 Views
Last Modified: 2010-04-17
Hello,

I have a VB.NET Sub routine with 3 parameters.  The last is " ByRef Optional ilsList As ImageList".

What the routine does internally varies, depending on whether it is called with an ImageList reference.  I therefore need to be able to check if this parameter was called.

I guess I need to assign a DEFAULT value to this reference... not sure how to do this.  I assumed maybe assigning NULL would work and allow me to do an ISREFERENCE() check against the ilsList object.  But this doesn't seem to work.

Any ideas?

Thanks in advance!
0
Comment
Question by:quiTech
3 Comments
 
LVL 1

Accepted Solution

by:
Edy_l earned 500 total points
ID: 12022776
I assume ilsList  is ImageList type object, so try this

Function A(ByRef Optional ilsList As ImageList = nothing)
     'do your checking here
     If not lsLists is nothing then
          '...some code
     End If
End Function

Cheers,
Ed


0
 
LVL 5

Expert Comment

by:tzxie2000
ID: 12022911
I think Edy_l is right
0
 

Author Comment

by:quiTech
ID: 12022956
Works great!  Thanks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

813 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now