(view source code of myfirsthta.hta as plain text)
body {background-color: #fdfeff;
color: darkblue;
font-family: Calibri;
font-size: 12pt;
margin: 4em 3em;
}Option Explicit
Sub CheckIfPrime( ) Dim i, intInput intInput = document.getElementById( "InputNumber" ).valueIf intInput < 3 Then
document.getElementById( "OutputResult" ).innerHTML = "Yes, " & intInput & " is a prime number."
ElseFor i = 2 To intInput - 1
If intInput Mod i = 0 Then
document.getElementById( "OutputResult" ).innerHTML = "No, " & intInput & " is not a prime number."
Exit Sub
End If
Nextdocument.getElementById( "OutputResult" ).innerHTML = "Yes, " & intInput & " is a prime number."
End If
End Sub
Sub ValidateInput( ) Dim objRE, strInput strInput = document.getElementById( "InputNumber" ).valueSet objRE = New RegExp
objRE.Global = True objRE.Pattern = "[^\d]+"If objRE.Test( strInput ) Then
strInput = objRE.Replace( strInput, "" ) document.getElementById( "InputNumber" ).value = strInputdocument.getElementById( "OutputResult" ).innerHTML = "Enter a number, and click the ""Check"" button to check if it is a prime number."
End If
If strInput = "" Then
document.getElementById( "OutputResult" ).innerHTML = "Enter a number, and click the ""Check"" button to check if it is a prime number."
End If
Set objRE = Nothing
End Sub
Sub Window_OnLoadwindow.resizeTo 640, 480
document.title = document.title & ", Version " & MyFirstHTA.VersionEnd Sub
</script><body><p><input type="text" id="InputNumber" onchange="ValidateInput" onkeyup="ValidateInput" /> <input type="button" value="Check" onclick="CheckIfPrime" /></p><p> </p>
<p id="OutputResult">Enter a number, and click the "Check" button to find out if it is a prime number.</p>
</body></html>page last modified: 2025-10-11; loaded in 0.1036 seconds