Get

The Get method takes the name of a counter and returns the current value of the counter. If the counter doesn't exist, the method creates it and sets it to 0.

Syntax

Counters.Get(CounterName)

 

Parameters
CounterName
A string containing the name of the counter.
Example

Display the value of a counter with <%= Counters.Get(CounterName) %>. The following script displays the vote tally from a poll about favorite colors.

--- Counters_Get.asp ---

<HTML>
<HEAD><TITLE>Voting for Colors</TITLE></HEAD>
<BODY>

<%
  vote = Request.QueryString("color")
  ' The Counters object was instantiated in Global.asa.
  Counters.Increment(vote & "counter") 
%>
<H3>Vote for your Favorite Color:</H3>
<FORM NAME="Voting for Colors" METHOD="GET" ACTION="Counters_Get.asp">
<input type="RADIO" NAME="color" VALUE="red">Red
<input type="RADIO" NAME="color" VALUE="green">Green
<input type="RADIO" NAME="color" VALUE="blue">Blue
<BR><INPUT TYPE="SUBMIT" VALUE="Submit Vote">
</FORM>
<H3>Current Vote Tally:</H3>
Red: <% =Counters.Get("redcounter") %><BR>
Green: <% = Counters.Get("greencounter") %><BR> 
Blue: <% = Counters.Get("bluecounter") %><BR>
</BODY>
</HTML>

 
See Also

Increment, Remove, Set


© 1997-2001 Microsoft Corporation. All rights reserved.