⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asp_ref_dictionary.asp@output=print

📁 W3Schools tutorial..web designing
💻 ASP@OUTPUT=PRINT
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>ASP Dictionary Object</title>
 
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />

<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />

<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>

</head>
<body>

<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>

<h1>ASP Dictionary Object</h1>
<a href="asp_ref_folder.asp"><img border="0" alt="previous" src="../images/btn_previous.gif" width="100" height="20" /></a>
<a href="asp_ado.asp"><img border="0" alt="next" src="../images/btn_next.gif" width="100" height="20" /></a>
<hr />

<p class="intro">The Dictionary object is used to store information in 
name/value pairs (referred to as key and item)</p>

<hr />

<h2>Examples</h2>

<p><a target="_blank" href="showasp.asp@filename=demo_exists">Does a specified key exist?</a><br />
This example demonstrates how to first create a Dictionary object, and then use
the Exists method to check if a specified key exists.</p>

<p><a target="_blank" href="showasp.asp@filename=demo_items">Return an array of all items</a><br />
This example demonstrates how to use
the Items method to return an array of all the items.</p>

<p><a target="_blank" href="showasp.asp@filename=demo_keys">Return an array of all keys</a><br />
This example demonstrates how to use
the Keys method to return an array of all the keys.</p>

<p><a target="_blank" href="showasp.asp@filename=demo_item">Return the value of an item</a><br />
This example demonstrates how to use
the Item property to return the value of an item.</p>

<p><a target="_blank" href="showasp.asp@filename=demo_key">Set a key</a><br />
This example demonstrates how to use
the Key property to set a key in a Dictionary object.</p>

<p><a target="_blank" href="showasp.asp@filename=demo_count">Return the number of key/item pairs</a><br />
This example demonstrates how to use
the Count property to return the number of key/item pairs.</p>

<hr />

<h2>The Dictionary Object</h2>
<p>The Dictionary object is used to store information in name/value pairs 
(referred to as key and item). The Dictionary object might seem similar to 
Arrays, however, the Dictionary object is a more desirable solution to 
manipulate related data.</p>

<p>Comparing Dictionaries and Arrays:</p>

<ul>
  <li>Keys are used to identify the items in a Dictionary object</li>
  <li>You do not have to call ReDim to change the size of the Dictionary object</li>
  <li>When deleting an item from a Dictionary, the remaining items will 
  automatically shift up</li>
  <li>Dictionaries cannot be multidimensional, Arrays can</li>
  <li>Dictionaries have more built-in functions than Arrays</li>
  <li>Dictionaries work better than arrays on accessing random elements 
  frequently</li>
  <li>Dictionaries work better than arrays on locating items by their content</li>
</ul>
<p>The following example creates a Dictionary object, adds some key/item 
pairs to it, and retrieves the item value for the key gr:</p>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
  <tr valign="top">
    <td valign="top">
      <pre>&lt;%
Dim d
Set d=Server.CreateObject(&quot;Scripting.Dictionary&quot;)
d.Add &quot;re&quot;,&quot;Red&quot;
d.Add &quot;gr&quot;,&quot;Green&quot;
d.Add &quot;bl&quot;,&quot;Blue&quot;
d.Add &quot;pi&quot;,&quot;Pink&quot;
Response.Write(&quot;The value of key gr is: &quot; &amp; d.Item(&quot;gr&quot;))
%&gt;</pre>
      <p>Output:</p>
      <pre>The value of key gr is: Green </pre>
    </td>
  </tr>
</table>
<p>The Dictionary object's properties and methods are described below: </p>

<h3>Properties</h3>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
  <tr valign="top">
    <th width="22%" align="left">Property</th>
    <th width="78%" align="left">Description</th>
  </tr>
  <tr valign="top">
    <td><a href="prop_comparemode.asp">CompareMode</a></td>
    <td>Sets or returns the comparison mode for comparing keys in a Dictionary 
    object</td>
  </tr>
  <tr valign="top">
    <td><a href="prop_count.asp">Count</a></td>
    <td>Returns the number of key/item pairs in a Dictionary object</td>
  </tr>
  <tr>
    <td valign="top"><a href="prop_item.asp">Item</a></td>
    <td valign="top">Sets or returns the value of an item in a Dictionary object</td>
  </tr>
  <tr>
    <td valign="top"><a href="prop_key.asp">Key</a></td>
    <td valign="top">Sets a new key value for an existing key value in a 
    Dictionary object</td>
  </tr>
</table>

<h3>Methods</h3>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
  <tr valign="top">
    <th width="22%" align="left">Method</th>
    <th width="78%" align="left">Description</th>
  </tr>
  <tr valign="top">
    <td><a href="met_add.asp">Add</a></td>
    <td>Adds a new key/item pair to a Dictionary object</td>
  </tr>
  <tr valign="top">
    <td><a href="met_exists.asp">Exists</a></td>
    <td>Returns a Boolean value that indicates whether a specified key exists in 
    the Dictionary object</td>
  </tr>
  <tr>
    <td valign="top"><a href="met_items.asp">Items</a></td>
    <td valign="top">Returns an array of all the items in a Dictionary
      object</td>
  </tr>
  <tr>
    <td valign="top"><a href="met_keys.asp">Keys</a></td>
    <td valign="top">Returns an array of all the keys in a Dictionary
      object</td>
  </tr>
  <tr>
    <td valign="top"><a href="met_remove.asp">Remove</a></td>
    <td valign="top">Removes one specified key/item pair from the Dictionary 
    object</td>
  </tr>
  <tr>
    <td valign="top"><a href="met_removeall.asp">RemoveAll</a></td>
    <td valign="top">Removes all the key/item pairs in the Dictionary object</td>
  </tr>
</table>

<br />
<hr />
<a href="asp_ref_folder.asp"><img border="0" alt="previous" src="../images/btn_previous.gif" width="100" height="20" /></a>
<a href="asp_ado.asp"><img border="0" alt="next" src="../images/btn_next.gif" width="100" height="20" /></a>

<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -