古蹟修復VBSCRIPT_BUTTON的應用

 

在vbscript中若要去進行
按鈕事件的註冊通常要而外寫一個subruntime來觸發

按鈕事件名稱則固定以
button名_OnClick

額外添加 _OnClick 後綴

而這類寫法會類似去省略額外在buton attribute中去定義onclick事件



Sub ButtonName_OnClick()
   ...place your code here
End Sub



寫法1.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<HTML>
<HEAD>
<TITLE>VBScript Test Page</TITLE>
</HEAD>

<BODY>

<HR>

<H2> No Comment Markers! </H2>

<CENTER><INPUT TYPE=BUTTON LANGUAGE="VBScript" VALUE="Test" NAME="TestButton">A
</CENTER>

<HR>


<SCRIPT LANGUAGE="VBScript">
       Sub TestButton_OnClick()
           MsgBox "You just clicked the Test button."
       End Sub
</SCRIPT>

</BODY>

</HTML>



寫法2. Button Event事件共用

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<HTML>

<HEAD>
<TITLE>The Button Control</TITLE>
</HEAD>

<BODY>
<H1>
<A HREF="http://www.mcp.com"><IMG  ALIGN=MIDDLE
SRC="../shared/jpg/samsnet.jpg" BORDER=2 HSPACE=20></A>
<EM>The Button Control</EM></h1>
<HR>

<CENTER><H2>Using the Explicit Event Procedure</H2></CENTER>

<P>This Web page demonstrates how to use an explicit event procedure to
call the same procedure when you click on two different buttons. Click
on either button and the same procedure will be called.

<P><INPUT TYPE="BUTTON" NAME="cmdButton1" VALUE="Button One"
LANGUAGE="VBScript" OncLICK="ShowMessage 1">
<P><INPUT TYPE="BUTTON" NAME="cmdButton2" VALUE="Button Two"
LANGUAGE="VBScript" OncLICK="ShowMessage 2">

<HR>




<SCRIPT LANGUAGE="VBScript">
<!--  Option Explicit

   Sub ShowMessage(ButtonValue)
      MsgBox "You have clicked on button #" & ButtonValue
   End Sub

-->
</SCRIPT>

</BODY></HTML>










留言

這個網誌中的熱門文章

何謂淨重(Net Weight)、皮重(Tare Weight)與毛重(Gross Weight)

Architecture(架構) 和 Framework(框架) 有何不同?_軟體設計前的事前規劃的藍圖概念

經得起原始碼資安弱點掃描的程式設計習慣培養(五)_Missing HSTS Header