Name Value Collecion in

By: Issac Emailed: 1698 times Printed: 2203 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

There is one datastructure in .net that is very similar to Hash table it is called as Name Value collection, which is used to store data in a unique format Name, Value format, Hash table stores in Key, value format but NameValueCollection can hold more than one value for a reference key.

Adding new pairs
Add (ByVal name As String, ByVal value As String) 
Add ("Rudran","80")
Get the value of corresponding Key
GetValues(ByVal name As String) As String() 
String values() = GetValues("Rudran")
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("A+", "80")
markStatus.Add("First Class", "60")
markStatus.Add("Average", "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 run this code you will get a key/value set which can be check the mark status of the students. Home | All Tutorials | Latest Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.

Bookmark and Share


Be the first one to add a comment

Your name (required):

Your email(required, will not be shown to the public):

Your sites URL (optional):

Your comments:

More Tutorials by Issac
Save/Write/Read image file from/to a database using Java program
How to modify the objects using java classes
Java program for Cloning
Java program for changeable wrapper class
A tutorial on Chat Server and Chat Client in
Chat Server in
Chat client in
How to open and read an XML file in
How to create an XML file in
XML and
How to create an XML file in VB.NET using Dataset
Multi Threaded Client Socket Programming in
Multi Threaded Server Socket Programming in
Multi threaded Socket Programming in
Client Socket Program sample in

More Tutorials in
Scope in
Unstructured Exception Handling in
Structured Exception Handling in
Creating Sub Procedures in
Creating Functions in
Passing a Variable Number of Arguments to Procedures in
Specifying Optional Arguments with default values in Procedures in
Preserving a Variable's Values between Procedure Calls in
Procedure Delegates in
Properties in
Understanding Scope in
Using Resume Next and Resume Line in
Using On Error GoTo 0 in
Getting an Exception's Number and Description in
Raising an Exception Intentionally in

More Latest News
Most Viewed Articles (in )
Nested If and Single line if statement
What is .NET Framework and the Common Language Runtime?
Update cell data in an Excel file using OLEDB in
Visual Basic Statements
Sub Procedures and Functions in
Name Value Collecion in
String Insert, index off & format in
String.Contains (), compare, clone in binary reader and writer
Using Excel 2007 Chart in VB.NET 2005
How to export from database to excel using
Your first VB.NET Crystal Reports - A step by step guide
Client Socket Program sample in
Chat client in
Creating Tree Views in Code using
Most Emailed Articles (in
How to export from database to excel using
Changes in Controls from VB6 to
What is .NET Framework and the Common Language Runtime?
While Loop in
Substring in Vb.Net String Class
Create an Excel 2007 file in VB.NET 2005
Insert Pictures in Excel 2007 from VB.NET 2005
Socket Programming in
Chat Server in
Using the ServiceBase Class in
Using Select Case in
String Insert, index off & format in
String Split function in text reader
Format Excel 2007 Page in VB.NET