Solved

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

Posted on 2009-05-06
2
1,110 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
2 Comments
 
LVL 12

Accepted Solution

by:
GuitarRich earned 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

705 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

19 Experts available now in Live!

Get 1:1 Help Now