Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,085 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,778 people online right now. Registration is fast and FREE... Join Now!




Calculator coding

 
Reply to this topicStart new topic

Calculator coding

mahicatchme
28 May, 2008 - 11:32 AM
Post #1

New D.I.C Head
*

Joined: 28 May, 2008
Posts: 2

CODE
Public Class Form1

    Private Sub Tb1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tb1.TextChanged

    End Sub

    Private Sub Bt1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt1.Click
        Tb1.Text = Tb1.Text & Bt1.Text
    End Sub

    Private Sub Bt2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt2.Click
        Tb1.Text = Tb1.Text & Bt2.Text
    End Sub

    Private Sub Bt3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt3.Click
        Tb1.Text = Tb1.Text & Bt3.Text
    End Sub

    Private Sub Bt4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt4.Click
        Tb1.Text = Tb1.Text & Bt4.Text
    End Sub

    Private Sub Bt5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt5.Click
        Tb1.Text = Tb1.Text & Bt5.Text
    End Sub

    Private Sub Bt6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt6.Click
        Tb1.Text = Tb1.Text & Bt6.Text
    End Sub

    Private Sub Bt7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt7.Click
        Tb1.Text = Tb1.Text & Bt7.Text
    End Sub

    Private Sub Bt8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt8.Click
        Tb1.Text = Tb1.Text & Bt8.Text
    End Sub

    Private Sub Bt9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt9.Click
        Tb1.Text = Tb1.Text & Bt9.Text
    End Sub

    Private Sub Bt0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt0.Click
        Tb1.Text = Tb1.Text & Bt0.Text
    End Sub

    Private Sub BtClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtClear.Click
        Tb1.Clear()
    End Sub

    Private Sub Btplus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btplus.Click
        Dim Total1 As Integer
        Total1 = Total1 + Val(Tb1.Text)
        Tb1.Clear()
    End Sub

    Private Sub Btequal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btequal.Click
        Dim Total2 As Integer
        Dim Total1 As Integer
        Total2 = Total1 + Val(Tb1.Text)

    End Sub

    Private Sub Btminus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btminus.Click
        Dim Total1 As Integer
        Total1 = Total1 + Val(Tb1.Text)
        Tb1.Clear()
    End Sub
End Class



Hello i just want to know what is the exact coding for the Button equal (Btequal)
User is offlineProfile CardPM
+Quote Post

dds
RE: Calculator Coding
28 May, 2008 - 09:26 PM
Post #2

New D.I.C Head
*

Joined: 28 May, 2008
Posts: 3


My Contributions
It would help us to help you if you would tell us what the program is expected to do. There are many buttons that combine strings contained in textboxes. It seems that when the equals button is pressed, it declares a procedure level variable and initializes it to 0, then adds textbox1 to it. The value isn't displayed anywhere because it is never assigned to a label or textbox of its own. It also seems that you are trying to use variables across subs. Variables die as soon as the procedure or class that they are declared in comes to an end. If you want to use variables across subs, you need to declare it with a broader scope. Try declaring the variable in the general declaration section (Directly beneath "Public class form1").
User is offlineProfile CardPM
+Quote Post

mahicatchme
RE: Calculator Coding
29 May, 2008 - 11:12 AM
Post #3

New D.I.C Head
*

Joined: 28 May, 2008
Posts: 2

QUOTE(dds @ 28 May, 2008 - 10:26 PM) *

It would help us to help you if you would tell us what the program is expected to do. There are many buttons that combine strings contained in textboxes. It seems that when the equals button is pressed, it declares a procedure level variable and initializes it to 0, then adds textbox1 to it. The value isn't displayed anywhere because it is never assigned to a label or textbox of its own. It also seems that you are trying to use variables across subs. Variables die as soon as the procedure or class that they are declared in comes to an end. If you want to use variables across subs, you need to declare it with a broader scope. Try declaring the variable in the general declaration section (Directly beneath "Public class form1").


User is offlineProfile CardPM
+Quote Post

Tim A
RE: Calculator Coding
30 May, 2008 - 11:41 AM
Post #4

New D.I.C Head
*

Joined: 3 Apr, 2008
Posts: 19

Can't tell what you're asking. Be a little more specific and I can help you. I have written a pretty decent calculator myself...
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 11:46PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month