Microsoft HTA/Using VBScript

Revision as of 22:58, 17 May 2022 by Dartz (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


One of Microsoft HTA's most notable features is its ability to be used as an easy way to make a front end for VBScript scripts. You already know that you can embed JavaScript in HTA through the script element. However, you can change the scripting language used from JavaScript to VBScript using the language attribute in the script element. In order to use VBScript in a script element, just set the value of the language attribute to VBScript exactly. In order to call VBScript subroutines from buttons, just set the onclick attribute to the function's name. There is an example of the usage of VBScript below.

Language: HTA
<!DOCTYPE html>

<html>
  <head>
    <title>HTA Test Program</title>
    <HTA:APPLICATION
      APPLICATIONNAME = "HTA Test Program"
    />
    <script language="VBScript">
      Sub ButtonPressed
        x=MsgBox("Hello, world!", 0+64, "HTA Test Program")
      End Sub
    </script>
  </head>
  <body>
    <h1>Press the button to open a message box.</h1>
    <button onclick="ButtonPressed">Click me</button>
  </body>
</html>