VBScript Number Game

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

KugarWeb

Thread Starter
Joined
Apr 6, 2007
Messages
143
Hi there,

I am currently working on a project which generates numbers and converts them into words, then asks the user how the number appears in digits and then finally compares the results and displays a "Correct" or "Incorrect" page.

So far I have got the numbers configured and have an idea on where to go next although I am having trouble with an error, which is on line 55 which is an "Expected statement" error, although I have closed all statements with the End Sub correctly.

Below are both lines 55 and 56.

Code:
Hun (9) = "nine-hundred"
End Sub
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
   <title>Welcome To The Number Game!</title>
</head>
<body bgcolor="#00ff00">
<div align="center" id="txtStart">Please press Start button to begin.</div>
<p align="center"><input type="button" value="Start" id="btnStart" />&nbsp;<input type="text" style="width:400px; height:18px;" id="txtAnswer" />&nbsp;<input type="button" value="Check" style="width=500px;" id="btnCheck" /></p>
<p align="center"><input type="text" style="width:400px; height:18px; font-size:20px;" id="txtResult" /></p>
</body>
</html>
<script language="vbscript">
Option Explicit
Dim Num(9)
Dim Ten(9)
Dim Hun(9)
Dim u
Dim t
Dim h
Dim result

Sub Window_OnLoad()
    Randomize
    For u = 1 To 9
    Num (1) = "one"
    Num (2) = "two"
    Num (3) = "three"
    Num (4) = "four"
    Num (5) = "five"
    Num (6) = "six"
    Num (7) = "seven"
    Num (8) = "eight"
    Num (9) = "nine"
    Next
    For t = 1 To 9
    Ten (1) = "ten"
    Ten (2) = "twenty"
    Ten (3) = "thirty"
    Ten (4) = "fourty"
    Ten (5) = "fifty"
    Ten (6) = "sixty"
    Ten (7) = "seventy"
    Ten (8) = "eighty"
    Ten (9) = "ninty"
    Next
    For h = 1 To 9
    Hun (1) = "one-hundred"
    Hun (2) = "two-hundred"
    Hun (3) = "three-hundred"
    Hun (4) = "four-hundred"
    Hun (5) = "five-hundred"
    Hun (6) = "six-hundred"
    Hun (7) = "seven-hundred"
    Hun (8) = "eight-hundred"
    Hun (9) = "nine-hundred"
End Sub

Sub btnStart_OnClick()
    txtStart.innerText = "What is " & Num(u) & Ten(t) & Hun(h) " in digits?"
    btnStart.disabled = true
End Sub

Sub result = & Num(u) & Ten(t) & Hun(h)
End Sub

Sub btnCheck_OnClick()
    If CInt(txtAnswer.value) = result Then
      txtResult.innerText = "Correct!"
      document.bgcolor = "#ffcc00"
    Else
      txtResult.innerText = "Sorry, please try again.  The answer was " & (result)
      document.bgcolor = "#ff0000"
    End If
  End Sub
</script>
If anyone can give me some help with this as soon as possible I would be most grateful. One note is that it does not even attempt to execute the rest of the code beyond line 55 which is to be expected.
 
Joined
Feb 12, 2008
Messages
46
I could be wrong but don't you need a Next statement before your End Sub

I think you have a For statement before the hundreds section... but final statement for that final For loop....
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top