Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parameters are being ignored
Message
 
To
05/06/2006 17:44:14
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01126998
Message ID:
01127232
Views:
17
This message has been marked as a message which has helped to the initial question of the thread.
Hi Michel,

Here is a little suggestion to refactor your original code in order to make it simplier and easier to maintain:
Private Function InList(ByVal searchedWord As String, ByVal ParamArray listOfWords() As String) As Boolean

    For Each word As String In listOfWords
        If word = searchedWord Then
            Return True
        End If
    Next
    Return False

End Function
It uses a feature from VB.NET (also existing in C#) called array parameters. The reserved word ParamArray at the function signature indicates that the function can receive a variable number of parameters from the second parameter on. The values passed as parameters are stored into an array and you can access its members as you'd normally do with regular arrays.

This makes your function work with an arbitrarly long list of parameters, which, IMHO, makes its design more flexible, optimized and robust.

HTH.
-----
Fabio Vazquez
http://www.fabiovazquez.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform