Best Practice + Adding Items

Posted on 2007-07-24
Last Modified: 2008-01-09
I have a control which accepts objects of type   ValueListItem, is the following the best way of adding multiple items. Or should I stick with a single vli as just set it to a new one each time

       Dim vli1 As New Infragistics.Win.ValueListItem
        vli1.DisplayText = "Direct Database Connection"
        Dim vli2 As New Infragistics.Win.ValueListItem
        vli2.DisplayText = "Connect via Web Service"
Question by:rocky050371
    1 Comment
    LVL 85

    Accepted Solution

    I would say the second option is better.  Then you don't have a ton of variables declared cluttering up the code:

        Dim vli As Infragistics.Win.ValueListItem

        vli = New Infragistics.Win.ValueListItem
        vli.DisplayText = "Direct Database Connection"

        vli = New Infragistics.Win.ValueListItem
        vli.DisplayText = "Connect via Web Service"

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video discusses moving either the default database or any database to a new volume.

    759 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

    10 Experts available now in Live!

    Get 1:1 Help Now