Hi EveryOne,

I am given only 2 days to finish my assignment in 2 days,but I'm only a biginner in HTML. .
I would like to ask anyone to please check if what is wrong in my code. .

<html>
<head>
<title>Lab Exercise</title>
</head>
<body>
<h2>Script Integration</h2>

<h3>Laboreatory Exercise 5 - Calculator </h3>
</br></br>

<input type="textbox" name="txtNUMBER" id="txtNUMBER"></br></br>

<input type="button" name="cmd7" Value="7" id="cmd7">
<input type="button" name="cmd8" Value="8" id="cmd8">
<input type="button" name="cmd9" Value="9" id="cmd9">
<input type="button" name="cmdADD" Value="+" id="cmdADD"></br>

<input type="button" name="cmd4" Value="4" id="cmd4">
<input type="button" name="cmd5" Value="5" id="cmd5">
<input type="button" name="cmd6" Value="6" id="cmd6">
<input type="button" name="cmdSUBTRACT" Value="-" id="cmdSUBTRACT"></br>

<input type="button" name="cmd1" Value="1" id="cmd1">
<input type="button" name="cmd2" Value="2" id="cmd2">
<input type="button" name="cmd3" Value="3" id="cmd3">
<input type="button" name="cmdMULTIPLY" Value="*" id="cmdMULTIPLY"></br>

<input type="button" name="cmd0" Value="0" id="cmd0">
<input type="button" name="cmdDOT" Value="." id="cmdDOT">
<input type="button" name="cmdEQUALS" Value="=" id="cmdEQUALS">
<input type="button" name="cmdDIVIDE" Value="/" id="cmdDIVIDE"></br>

<input type="button" name="cmdClear" Value="Clear" id="cmdClear">



</body>

<script language="vbscript">

Dim mfirst As Single
Dim msecond As Single
Dim manswer As Single
Dim mbutton As Integer
Dim Signstate As Boolean

Private Sub cmd0_onClick()

txtNUMBER = txtNUMBER + "0"
End Sub

Private Sub cmd1_onClick()

txtNUMBER = txtNUMBER + "1"
End Sub

Private Sub cmd2_onClick()

txtNUMBER = txtNUMBER + "2"
End Sub

Private Sub cmd3_onClick()

txtNUMBER = txtNUMBER + "3"
End Sub

Private Sub cmd4_onClick()

txtNUMBER = txtNUMBER + "4"
End Sub

Private Sub cmd5_onClick()

txtNUMBER = txtNUMBER + "5"
End Sub

Private Sub cmd6_onClick()

txtNUMBER = txtNUMBER + "6"
End Sub

Private Sub cmd7_onClick()

txtNUMBER = txtNUMBER + "7"
End Sub

Private Sub cmd8_onClick()

txtNUMBER = txtNUMBER + "8"
End Sub

Private Sub cmd9_onClick()

txtNUMBER = txtNUMBER + "9"
End Sub

Private Sub cmdADD_onClick()

mbutton = 1

mfirst = Val(txtNUMBER)

txtNUMBER = ""
End Sub

Private Sub cmdClear_onClick()
txtNUMBER = " "
End Sub

Private Sub cmdDIVIDE_onClick()

mbutton = 4

mfirst = Val(txtNUMBER)

txtNUMBER = ""
End Sub

Private Sub cmdDOT_onClick()
txtNUMBER = txtNUMBER + "."
End Sub

Private Sub cmdEQUALS_onClick()
msecond = Val(txtNUMBER)

Select Case mbutton
Case Is = 1
manswer = mfirst + msecond
Case Is = 2
manswer = mfirst - msecond
Case Is = 3
manswer = mfirst * msecond
Case Is = 4
manswer = mfirst / msecond
End Select
txtNUMBER = manswer
End Sub

Private Sub cmdMULTIPLY_onClick()

mbutton = 3

mfirst = Val(txtNUMBER)

txtNUMBER = ""
End Sub

Private Sub cmdSUBTRACT_onClick()

mbutton = 2

mfirst = Val(txtNUMBER)

txtNUMBER = ""
End Sub



</script>

</html>

Recommended Answers

All 4 Replies

I'll tell you one thing. Heading should be:

<h3>Laboratory</h3>

</br> should be <br> for html and <br /> for xhtml. There is no such thing as </br>.

Also, why are you using vbscript? You do know vbscript only works in Internet Explorer right? Use JavaScript.

<input type="textbox" disabled='disabled' style='text-align:right;' name="txtNUMBER" id="txtNUMBER"> to make the numbers pushin from the right like a standard calc. and numbers can only be entered by keypad, not directly in the box

Thank you so much for the effort guys,but the problem is when I click the button nothing happens. .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.