VBScript help

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

TWD

Cute and Cuddly
Aug 2, 2000
7,445
16
38
38
Salt Lake City UT
members.lycos.co.uk
I've got this nice test that my friend wrote in Java, it's kinda got a problem though. First off it asks you a yes or no question but there's only a ok or cancel button on the thing. It's basically an error message box like thing that comes up. Another thing is that this test is LONG. 512 questions in total. After a while the computer seems to stop trying to get the whole thing so it stops. You can't get through it all. I was told VB script would help.

I've been reading a few tutorials and I have figured out that VB script is very very easy. The problem I'm having right now is that I can't find a very good tutorial none of them teach me all that I want.

So basically is what I want is the question above, and then a yes button and a no button so they can answer. I figured out that <INPUT NAME="Yes" TYPE="Button" SIZE=4 VALUE="Yes" ONCLICK="UpdateMessage" WIDTH=100%>
<INPUT NAME="No" TYPE="Button" SIZE=4 VALUE="No" ONCLICK="UpdateMessage" WIDTH=100%>
Will make the buttons for me. Then after that i need
<script language=VBScript>
This is where I'm stuck. I can make text display on the screen with the
document.write("
command. I also know how to use an if then stament by using the
If x=x then
stuff
stuff
stuff
end if
lines. What I don't know is how I make it so that it will add 1 to the varriable correct when it presses the yes button or add nothing if they say no, and then display the next question. So first off tell me what I use to make it respond when the button is pushed, and second tell me where I can find a nice tutorial.
 
I don't completely remember VBscript syntax, since I usually use JavaScript, but I beleive something like the following will do what you're asking:

In the HEAD section of your page, put the following code
Code:
<SCRIPT LANGUAGE="VBScript">
var number_correct

sub buttonYes ()
  ...
  [I]code to check if this is correct, and if so, increment the number_correct variable[/I]
  ...
end sub

sub buttonNo ()
 ...
  [I]code to check if this is correct, and if so, increment the number_correct variable[/I]
  ...
end sub
</SCRIPT>
and then whereever you want the buttons:
Code:
<INPUT NAME="Yes" TYPE="Button" SIZE=4 VALUE="Yes" ONCLICK="buttonYes" WIDTH=100%>
<INPUT NAME="No" TYPE="Button" SIZE=4 VALUE="No" ONCLICK="buttonNo" WIDTH=100%>