Ekkehard.Horner幫助了我很多與下面的代碼(我已經修改)。但是現在我正在尋找一種方法來在每次顯示MsgBox "message 1"
時添加一個計數器。不同的MsgBox每次迭代後
<html>
<head>
<title>Sync Tool</title>
<HTA:APPLICATION
APPLICATIONNAME="Sync Tool"
ID="SyncTool"
VERSION="1.0.0"
BORDER="dialog"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="no"
SCROLL="no"
SINGLEINSTANCE="yes"
CONTEXTMENU="no"
SELECTION="no"/>
</head>
<script language="VBScript">
Set objShell = CreateObject("WScript.Shell")
Sub Window_OnLoad
Dim width, height
width = 330
height = 310
self.ResizeTo width, height
self.MoveTo (screen.AvailWidth-width)/2, (screen.AvailHeight-height)/2
End Sub
Sub OnClickButtonSyncNow()
' Box A
If BoxAA.checked Then
MsgBox "BoxAA"
Else
'Do nothing
End If
If BoxAB.checked Then
MsgBox "BoxAB"
Else
'Do nothing
End If
If BoxAC.checked Then
MsgBox "BoxAC"
Else
'Do nothing
End If
If BoxAD.checked Then
MsgBox "BoxAD"
Else
'Do nothing
End If
If BoxAE.checked Then
MsgBox "BoxAE"
Else
'Do nothing
End If
' Box B
If BoxBA.checked Then
MsgBox "BoxBA"
Else
'Do nothing
End If
If BoxBB.checked Then
MsgBox "BoxBB"
Else
'Do nothing
End If
If BoxBC.checked Then
MsgBox "BoxBC"
Else
'Do nothing
End If
If BoxBD.checked Then
MsgBox "BoxBD"
Else
'Do nothing
End If
If BoxBE.checked Then
MsgBox "BoxBE"
Else
'Do nothing
End If
Dim bF : bF = False
Dim c1
For Each c1 In Split("A B C D E F G H I J")
Dim n : n = c1
Dim b : Set b = document.getElementById(n)
If b.Checked Then
bF = True
End If
Next
If bF Then
MsgBox "all done"
Else
MsgBox "message 1"
End If
End Sub
Sub ExitTool()
window.close()
End Sub
</script>
<body bgcolor="firebrick">
<style type="text/css">
.tg {border-collapse:collapse;border-spacing:0;}
.tg th{font-family:Arial, sans-serif; font-size:14px; font-weight:normal; padding-top:0px ;padding-right:20px; padding-bottom:0px; padding-left:0px ;border-style:solid; border-width:0px; overflow:hidden; word-break:normal;}
.tg td{font-family:Arial, sans-serif; font-size:14px; padding-top:5px ;padding-right:10px; padding-bottom:0px; padding-left:0px ;border-style:solid; border-width:0px; overflow:hidden; word-break:normal;}
.tg .tg-header{color:#FFFB00; font-size:22px; font-weight:bold; font-family:Verdana, Geneva, sans-serif !important;}
.tg .tg-text{color:white; font-family:Verdana, Geneva, sans-serif !important; vertical-align:top}
.button {height:50px; width:136px; font-weight:bold; background-color:#555555; border: 2px solid #FFFB00; color:white; text-align:center; text-decoration:none; display:inline-block; font-size:16px;}
</style>
<table class="tg">
<tr>
<th class="tg-header">Box A</th>
<th class="tg-header">Box B</th>
</tr>
<tr>
<td class="tg-text"><input type="checkbox" name="BoxAA" id="A">AA</td>
<td class="tg-text"><input type="checkbox" name="BoxBA" id="B">BA</td>
</tr>
<tr>
<td class="tg-text"><input type="checkbox" name="BoxAB" id="C">AB</td>
<td class="tg-text"><input type="checkbox" name="BoxBB" id="D">BB</td>
</tr>
<tr>
<td class="tg-text"><input type="checkbox" name="BoxAC" id="E">AC</td>
<td class="tg-text"><input type="checkbox" name="BoxBC" id="F">BC</td>
</tr>
<tr>
<td class="tg-text"><input type="checkbox" name="BoxAD" id="G">AD</td>
<td class="tg-text"><input type="checkbox" name="BoxBD" id="H">BD</td>
</tr>
<tr>
<td class="tg-text"><input type="checkbox" name="BoxAE" id="I">AE</td>
<td class="tg-text"><input type="checkbox" name="BoxBE" id="J">BE</td>
</tr>
</table>
<br>
<input type="button" class="button" name="SyncNow" id="SyncNow" value="Sync Now" onclick="OnClickButtonSyncNow">
<input type="button" class="button" name="Exit" id="Exit" value="Exit" onclick="ExitTool">
</body>
</html>
我在尋找的結果是這樣的:
If bF Then
MsgBox "all done"
window.close()
Else
MsgBox "message 1" 'counter + 1
ElseIf counter = 2 Then
MsgBox "message 2" 'counter + 1
ElseIf counter = 3 Then
MsgBox "message 3" 'counter + 1
ElseIf counter = 4 Then
MsgBox "message 4" 'counter + 1
ElseIf counter = 5 Then
MsgBox "message 5" 'no more counting needed because of window.close()
window.close()
End If
我喜歡嘗試不同Do..Loop
的東西,但我從來沒有計數器超出1 真的在努力瞭解統計的基礎知識VBScript中。
當點擊一個按鈕,所有選項都被取消話,就說明消息1。但我要完成的,是每次按鈕顯示新郵件點擊並且所有複選框仍未選中,並且需要在5封郵件後停止。我將在今晚晚些時候更新我的第一篇文章,以添加整個HTA。 – WatskeBart
剛剛在第一篇文章中加入完整的HTA – WatskeBart