Dim popytka1
Dim popytka2
popytka1 = Cbyte(1)
popytka2 = Cbyte(1)

Sub znaok1_OnClick
Dim otwet,potwet,tochn

' Правильный ответ
potwet=CDbl(0.788)
tochn=CDbl(0.001)

' Проверка вводимого числа (Текст или не текст)
If (Document.ans1.zna1.value="") OR (Not IsNumeric(Document.ans1.zna1.value)) Then
Alert "Необходимо ввести число"
ans1.zna1.focus
Exit Sub
End If

' Проверка вводимого числа (на попадание в диапазон)
otwet=CDbl(Document.ans1.zna1.value)
If ((Abs(otwet - potwet) <= tochn) AND (popytka1 <= 3)) or ( (Abs(otwet - potwet) > tochn) AND ((popytka1 >= 1)and(popytka1 <= 3))) Then 
   Top.Hlp.Help.Document.Open
   Top.Hlp.Help.Document.Write "<HTML>"
   Top.Hlp.Help.Document.Write "<HEAD><meta http-equiv='Content-Type' content='text/html; charset=windows-1251'><STYLE>"
   Top.Hlp.Help.Document.Write "A { text-decoration: none}"
   Top.Hlp.Help.Document.Write "A:hover {text-decoration: underline; color: #FF00FF}"
   Top.Hlp.Help.Document.Write "BODY {background-image : URL(img/b_help.gif); font-variant: normal; font-family: Times New Roman; background-color: #DFEFFF; color: black;}"
   Top.Hlp.Help.Document.Write "</STYLE></HEAD>"
   Top.Hlp.Help.Document.Write "<BODY LINK='#0000FF' ALINK='#0000FF' VLINK='#0000FF'>"
End If
If (Abs(otwet - potwet) <= tochn) AND (popytka1 <= 3) Then 
   Top.Hlp.Help.Document.Write "Контрольная задача 1: <font color=#009933><b>Ответ верный !</B></font><BR>"
   Top.Hlp.Help.Document.Write "<A HREF=z4.htm TARGET=Main>Выход в меню занятия</A>"
   popytka1 = 5
ElseIf (Abs(otwet - potwet) > tochn) AND (popytka1 = 1) Then 
   Top.Hlp.Help.Document.Write "Контрольная задача 1: <font color=#FF0066><b>Ответ не верный !</B></font><BR>"
   Top.Hlp.Help.Document.Write "<font color=#99CC00><B>Осталось две попытки</B></FONT>."
   popytka1 = popytka1 + 1
ElseIf (Abs(otwet - potwet) > tochn) AND (popytka1 = 2) Then
   Top.Hlp.Help.Document.Write "Контрольная задача 1: <font color=#FF0066><b>Ответ не верный !</B></font><BR>"
   Top.Hlp.Help.Document.Write "<font color=#FF9900><B>Осталась последняя попытка</B></font>."
   popytka1 = popytka1 + 1
ElseIf (Abs(otwet - potwet) > tochn) AND (popytka1 = 3) Then
   Top.Hlp.Help.Document.Write "<font color=#FF3399><b>Контрольная задача 1 не решена !</B></FONT><BR>"
   Top.Hlp.Help.Document.Write "<A HREF=z4.htm TARGET=Main>Выход в меню занятия</A>"
   popytka1 = popytka1 + 1
End If

If ((Abs(otwet - potwet) <= tochn) AND (popytka1 <= 3)) or ( (Abs(otwet - potwet) > tochn) AND ((popytka1 >= 1)and(popytka1 <= 3))) Then 
   Top.Hlp.Help.Document.Write "</BODY>"
   Top.Hlp.Help.Document.Write "</HTML>"
   Top.Hlp.Help.Document.Close
End If

End Sub

Sub znaok2_OnClick
Dim otwet,potwet,tochn

' Правильный ответ
potwet=CDbl(2.0)
tochn=CDbl(0.0)

' Проверка вводимого числа (Текст или не текст)
If (Document.ans2.zna2.value="") OR (Not IsNumeric(Document.ans2.zna2.value)) Then
Alert "Необходимо ввести число"
ans2.zna2.focus
Exit Sub
End If

' Проверка вводимого числа (на попадание в диапазон)
otwet=CDbl(Document.ans2.zna2.value)
If ((Abs(otwet - potwet) <= tochn) AND (popytka2 <= 3)) or ( (Abs(otwet - potwet) > tochn) AND ((popytka2 >= 1)and(popytka2 <= 3))) Then 
   Top.Hlp.Help.Document.Open
   Top.Hlp.Help.Document.Write "<HTML>"
   Top.Hlp.Help.Document.Write "<HEAD><meta http-equiv='Content-Type' content='text/html; charset=windows-1251'><STYLE>"
   Top.Hlp.Help.Document.Write "A { text-decoration: none}"
   Top.Hlp.Help.Document.Write "A:hover {text-decoration: underline; color: #FF00FF}"
   Top.Hlp.Help.Document.Write "BODY {background-image : URL(img/b_help.gif); font-variant: normal; font-family: Times New Roman; background-color: #DFEFFF; color: black;}"
   Top.Hlp.Help.Document.Write "</STYLE></HEAD>"
   Top.Hlp.Help.Document.Write "<BODY LINK='#0000FF' ALINK='#0000FF' VLINK='#0000FF'>"
End If
If (Abs(otwet - potwet) <= tochn) AND (popytka2 <= 3) Then 
   Top.Hlp.Help.Document.Write "Контрольная задача 2: <font color=#009933><b>Ответ верный !</B></font><BR>"
   Top.Hlp.Help.Document.Write "<A HREF=z4.htm TARGET=Main>Выход в меню занятия</A>"
   popytka2 = 5
ElseIf (Abs(otwet - potwet) > tochn) AND (popytka2 = 1) Then 
   Top.Hlp.Help.Document.Write "Контрольная задача 2: <font color=#FF0066><b>Ответ не верный !</B></font><BR>"
   Top.Hlp.Help.Document.Write "<font color=#99CC00><B>Осталось две попытки</B></FONT>."
   popytka2 = popytka2 + 1
ElseIf (Abs(otwet - potwet) > tochn) AND (popytka2 = 2) Then
   Top.Hlp.Help.Document.Write "Контрольная задача 2: <font color=#FF0066><b>Ответ не верный !</B></font><BR>"
   Top.Hlp.Help.Document.Write "<font color=#FF9900><B>Осталась последняя попытка</B></font>."
   popytka2 = popytka2 + 1
ElseIf (Abs(otwet - potwet) > tochn) AND (popytka2 = 3) Then
   Top.Hlp.Help.Document.Write "<font color=#FF3399><b>Контрольная задача 2 не решена !</B></FONT><BR>"
   Top.Hlp.Help.Document.Write "<A HREF=z4.htm TARGET=Main>Выход в меню занятия</A>"
   popytka2 = popytka2 + 1
End If
If ((Abs(otwet - potwet) <= tochn) AND (popytka2 <= 3)) or ( (Abs(otwet - potwet) > tochn) AND ((popytka2 >= 1)and(popytka2 <= 3))) Then 
   Top.Hlp.Help.Document.Write "</BODY>"
   Top.Hlp.Help.Document.Write "</HTML>"
   Top.Hlp.Help.Document.Close
End If
End Sub