Set

Set 메서드는 카운터의 이름을 취하여 카운터를 정수 값으로 설정하고 새 값을 반환합니다. 카운터가 없으면 Counters.Set은 카운터를 만들고 정수 값으로 설정합니다.

카운터의 값을 검색하려면 Counters.Get을 사용하고 카운터를 1씩 증가시키려면 Counters.Increment를 사용합니다.

구문

Counters.Set( CounterName, int )

매개 변수

CounterName
카운터의 이름이 들어 있는 문자열입니다.
int
CounterName의 새로운 정수 값입니다.

예제

다음은 투표를 다시 설정하는 코드입니다.

--- Counters_Set.asp ---

<HTML>
<HEAD><TITLE>Voting for Colors</TITLE></HEAD>
<BODY>
<%
  red = Request.QueryString("red")
  green = Request.QueryString("green")
  blue = Request.QueryString("blue")
  ' The Counters object was instantiated in Global.asa.
  If IsNumeric(red) Then
    Counters.Set "redcounter", red
  End If
  If IsNumeric(green) Then
    Counters.Set "greencounter", green
  End If
  If IsNumeric(blue) Then
    Counters.Set "bluecounter", blue
  End If
%>
<H3>Doctor the Vote:</H3>
<FORM NAME="Doctoring the Vote" METHOD="GET" ACTION="Counters_Set.asp">
Red <input type="TEXT" NAME="red"><BR>
Green <input type="TEXT" NAME="green"><BR>
Blue <input type="TEXT" NAME="blue"><BR>
<BR><INPUT TYPE="SUBMIT" VALUE="Submit">
</FORM>
<H3>Current Vote Tally:</H3>
Red: <% =Counters.Get("redcounter") %><BR>
Green: <% = Counters.Get("greencounter") %><BR> 
Blue: <% = Counters.Get("bluecounter") %>
</BODY>
</HTML>
 

관련 항목

Get, Increment, Remove


© 1997-2001 Microsoft Corporation. All rights reserved.