none
VB 2010 Calculation Code

    Question

  • Hello guys,

     

    I'm having a problem about the code for my project.

    let say, I've created 2 Textbox, 1Textbox you will going to input the number for example 100 and the other Textbox will show the answer.

    Formula is:

     

    Textbox1-       100

    multifly by -    0.02

    TextBox2 =        2

    want to be the answer will show to box 2.

    can you guys teach me how to code this one.

    Thanks a lot

     

    More Power Guys!

     

    Starmax

     

    Saturday, October 30, 2010 6:59 AM

Answers

  • Yeah... I finally found it i try this code then it worked

     

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

            TextBox2.Text = Val(TextBox1.Text) * 0.02


        End Sub
    End Class

     

    Thanks jwavila and Cor Lightert for your concern keep it up..

     

    More Power VB Team!

     

    Cheers!

    Starmax

     

    now I found a new Home....

    Saturday, October 30, 2010 7:33 AM

All replies

  • can you show the code you have tried?

    you'll want to use Double.TryParse to check if what is entered into Textbox1 is actually a valid number. If it is, just multiply that number times 0.02 (using number * 0.02).

    to assign this number to a TextBox, then use the ToString method on the number

     

    Saturday, October 30, 2010 7:07 AM
  • Starmax,

    Definitely homework, that does not mean we will not help you, but we will not make your homework for you, so show your current code, be aware it is not as easy as it maybe looks.


    Success
    Cor
    Saturday, October 30, 2010 7:22 AM
  • Hello jwavila,

     

    Thanks for a quick reply, actually i dont know really know the code.

    But here is what it came up in my mind, unfinishe...

    my code is.

     

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
            If TextBox1.Text = Val() Then
        End Sub

     

    my code is untill here them I'm Stocked.. I dont know whats next.

    i want it to be, after you input the number to textbox 1 the answer will show up automatically to the textbox2.

     

    Thanks Again.

    Saturday, October 30, 2010 7:23 AM
  • Yeah... I finally found it i try this code then it worked

     

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

            TextBox2.Text = Val(TextBox1.Text) * 0.02


        End Sub
    End Class

     

    Thanks jwavila and Cor Lightert for your concern keep it up..

     

    More Power VB Team!

     

    Cheers!

    Starmax

     

    now I found a new Home....

    Saturday, October 30, 2010 7:33 AM
  • Try this.  Type "abc" into your Textbox1.  Don't you need to add error checking?  That is the real problem inside of the problem.


    Mark the best replies as answers. "Fooling computers since 1971."

    http://rudedog2.spaces.live.com/default.aspx

    • Proposed as answer by Renee Culver Saturday, December 01, 2012 8:31 AM
    Saturday, October 30, 2010 12:27 PM
  • hye, can you help me....i need source code for.....

    i have 4 textbox and 1 label

    what i wanna do is
    textbox1 * textbox2 / textbox3 / textbox4

    and the answer show up in label1.....automatically show up....
    i hope you can help me....

    Thursday, November 29, 2012 9:13 PM
  • yes, i've the code.....

    Public Class Form1

        Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox1.TextChanged
            TextBox5.Text = Val(TextBox1.Text) * Val(TextBox2.Text) / Val(TextBox3.Text) / Val(TextBox4.Text)

        End Sub

        Private Sub TextBox2_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox2.TextChanged
            TextBox5.Text = Val(TextBox1.Text) * Val(TextBox2.Text) / Val(TextBox3.Text) / Val(TextBox4.Text)

        End Sub

        Private Sub TextBox3_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox3.TextChanged
            TextBox5.Text = Val(TextBox1.Text) * Val(TextBox2.Text) / Val(TextBox3.Text) / Val(TextBox4.Text)

        End Sub

        Private Sub TextBox4_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox4.TextChanged
            TextBox5.Text = Val(TextBox1.Text) * Val(TextBox2.Text) / Val(TextBox3.Text) / Val(TextBox4.Text)

        End Sub
    End Class
    • Proposed as answer by No Saben Friday, November 30, 2012 9:32 PM
    Friday, November 30, 2012 9:32 PM