Vb.Net-Informations.com

  How to VB.Net NameValueCollection




   Categories

    HOME
    VB.NET
    CSHARP

 
   














How to VB.Net NameValueCollection

NameValueCollection is used to store data like Name, Value format. It is very similar to Vb.Net HashTable, HashTable also stores data in Key , value format . NameValueCollection can hold more than one value for a corresponding Key.

Adding new pairs

Add(ByVal name As String, ByVal value As String)

Add("High","80")

Get the value of corresponding Key

GetValues(ByVal name As String) As String()

String values() = GetValues("High")


         VB.NET Source Code Download           Print Source Code
         How to VB.Net NameValueCollection - Download
        
VB.Net Tutorial

Imports System.Collections.Specialized
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click

        Dim markStatus As New NameValueCollection
        Dim key As String
        Dim values() As String

        markStatus.Add("Very High", "80")
        markStatus.Add("High", "60")
        markStatus.Add("medium", "50")
        markStatus.Add("Pass", "40")

        For Each key In markStatus.Keys
            values = markStatus.GetValues(key)
            For Each value As String In values
                MsgBox(key & " - " & value)
            Next value
        Next key

    End Sub
End Class

When you execute this source code , you will get each Key/Value sets.

VB.NET Collections Related Contents
*     How to use VB.NET ArrayList
*     How to use VB.NET HashTable
*     How to use VB.NET Stack
*     How to use VB.NET Queue
*     How to use VB.NET Arrays
*     How to use VB.NET Dyanamic Arrays

VB.Net Related Topics
*     Microsoft .Net Framework Tutorials
*     VB.NET Language Basics Tutorials
*     VB.NET Program Flow Control Tutorials
*     VB.NET Collections Tutorials
*     VB.NET String Tutorials
*     VB.NET Files Tutorials
*     VB.NET Excel 2007 Tutorials
*     VB.NET Crystal Reports Tutorials
*     VB.NET Communications Tutorial
*     VB.NET ADO.NET Tutorial with source code
*     ADO.NET Data Providers help and Tutorial
*     VB.NET ADO.NET Dataset Tutorial
*     ADO.NET DataAdapter and Dataset
*     VB.NET ADO.NET DataView Tutorial
*     VB.NET Remoting Tutorial
*     VB.NET XML Tutorial
Search here for more CSharp Source Code :

  |  Home   |  SiteMap   |  About   |
net-informations.com (C) 2010 All Rights Reserved