Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB.NET - giving a default value to an Arraylist in a function paraments list

Posted on 2009-05-06
2
Medium Priority
?
1,174 Views
Last Modified: 2012-05-06
Hi

I have declared a function that returns to me some data, the thing is one of its parameters is an ArrayList and it's an optional parameter. check the code below.


As you see, I said {Optional ByVal Editable As ArrayList = Nothing} and it gives me an error on run time, so I thought the default value I gave to the optional arraylist is wrong, so what shall I put instead of 'Nothing'? I want it to be an arraylist of no data included if the user did not pass anything to that function.
Public Shared Function DisplayRequestMainData(ByVal Col1Contents As ArrayList, ByVal Col2Contents As ArrayList, Optional ByVal TableTitle As String = "Request Main Data", Optional ByVal Editable As ArrayList = Nothing) As String
 
[SOME CODE HERE]
 
End Function

Open in new window

0
Comment
Question by:alfardan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
GuitarRich earned 2000 total points
ID: 24312871
In your code are you checking that the arraylist is not nothing before you use it?
Like this:
If Not Editable Is Nothing Then
End If
0
 

Author Closing Comment

by:alfardan
ID: 31578381
Thanks, I put this condition and it worked
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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 …
Six Sigma Control Plans

719 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