Solved

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

Posted on 2009-05-06
2
1,145 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET Calendar Control 5 49
reading an excel file vb.net 2 44
How to call new form in VB2013? 4 30
MCAT Verbal Reasoning 2 19
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

738 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