# Calculator Troubles

Page 1 of 1

## 2 Replies - 559 Views - Last Post: 22 November 2007 - 12:32 PMRate Topic: 1 Votes //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=37945&amp;s=3e4b13f2fc40d40b7e65dceca11c949c&md5check=' + ipb.vars['secure_hash'], cur_rating: 1, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 hironakamura

Reputation: 0
• Posts: 18
• Joined: 20-September 07

# Calculator Troubles

Posted 22 November 2007 - 10:08 AM

Helo, i'm having quite a bit of trouble with a calculator i'm trying to make, i have the + working so i can get 7+7 to come up as 14 when i press =

But when i do something like 6-3 it comes up as 6 (the first number i entered)

It does the same with the divide and the multiply

heres the code for the Subtract

Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
'Make sure out input box has a value
If TextBox1.Text.Length <> 0 Then
'Check the value of our function flag
If calcFunc = String.Empty Then 'Flag is empty
'Assign the value in our input
'box to our holder
valHolder1 = CType(TextBox1.Text, Double)
'Empty the input box
TextBox1.Text = String.Empty
Else 'Flag isnt empty
'Call our calculate totals method
calculatetotals()
End If
'Assign a value to our calc function flag
calcFunc = "subtract"
'Toggle the decimal flag
hasDecimal = False
End If
End Sub

I use the same code for add but i change calcfunc = "subtract" to

calcfunc = "Multiply"
calcfunc = "Divide"

Etc

thanks

Is This A Good Question/Topic? 0

## Replies To: Calculator Troubles

• D.I.C Regular

Reputation: 6
• Posts: 334
• Joined: 08-October 07

## Re: Calculator Troubles

Posted 22 November 2007 - 11:39 AM

From what I see, it may be something in your actual calculatetotals() function that's causing the problem. As is, we can't see what the flag actually does once its set.

This tutorial may also be of some help to you.

### #3 hironakamura

Reputation: 0
• Posts: 18
• Joined: 20-September 07

## Re: Calculator Troubles

Posted 22 November 2007 - 12:32 PM

Thanks alot foir the help.

Page 1 of 1

 Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).