1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

VBScript Number Game

Discussion in 'Software Development' started by KugarWeb, Apr 9, 2008.

Thread Status:
Not open for further replies.
  1. KugarWeb

    KugarWeb Thread Starter

    Apr 6, 2007
    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.

    Hun (9) = "nine-hundred"
    End Sub
    <!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" >
       <title>Welcome To The Number Game!</title>
    <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>
    <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()
        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"
        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"
        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"
          txtResult.innerText = "Sorry, please try again.  The answer was " & (result)
          document.bgcolor = "#ff0000"
        End If
      End Sub
    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.
  2. PrurientCherubim


    Feb 12, 2008
    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....
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 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/701928

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice