numeric calculations problems

Hi guys,

I have a problem in working out some calculations within a form.
My form is called, claddagh_database, which is linked to data from an access database using Jet 4.0

I have some fields with money values in, Total value inc VAt, Deposit, Stage Payment & Balance Payment.

In access I had a field called Money Due, which was calculated using the expression  Sum=([Total Value Inc Vat]-[Deposit]-[Stage Payment]-[Balance Payment]
This then showed how much the customer still owes.

The thing is, I cant seem to do this in VB.NET..... ( or find an equivelant function )
I have looked in a few books I have, website etc etc, and just cant seem to find a solution as how to do this.
Firstly, is this possible
If so, where the hell would I start, and can it be done easily.

Any advice, help etc would be most greatly appreciated.
Please be simple in answers as I`m new to all this, im a newbie in programming, and VB.NET is what Im learning as my chosen language.

Thanks in advance.

Best wishes
Max Vernon




Answer this question

numeric calculations problems

  • oi2002

    Hello,

    Managed to get my drop down menu working in the datagrid thingy.

    Just a quick question, I have bound my data to where it need to get it from.
    When I compile the program, and run it, I go to where this datagrid is ( Which now has drop down box ) The correct data is in there, but there are multiple instances of the same data.

    Have I done something wrong here, maybee slected the source many times with out knowing.

    Thanks in advance, and thanks for the last lost of help.
    Oh, the MSDN place is an excellent info place with lots of easy to understand examples, so thanks for the pointer.

    Best Wishes
    Max Vernon

  • David T

    It is actual VB SAMPLE code, ... you must have the textbox and/or labels named appropriately on your form....

    ie "TextBox7" what does it contain if it is the Total Value Inc Vat then you should rename it accordingly...You can use the textbox changed event.

    As a newbie take some time and look into the Explicit Option.  When it is turned on it will help you avoid conversion and casting errors!

    The only dumb question is the one not asked!

  • StuMan1337

    If these values are bound to a label or textbox on your form then you could do something like this....

    MySumLabel.Text = (TotalValueIncVatLabel.text - DepositTextbox.text - StagepayementTextbox.text - BalanceTextbox.text)

    If you have option explicit turned on (which is a good idea) then you have to explicitly convert each value:

    Dim Result as Double= Convert.ToDouble(TotalValueIncVatLabel.text )- Convert.ToDouble(DepositTextbox.text) - Convert.ToDouble(StagepayementTextbox.text) - Convert.ToDouble(BalanceTextbox.text)

    MySumLabel.Text=Result.ToString

  • MBaig

    If you want to re-calculate when any of these values change then put the calculation in a separate procedure like
    Private sub CalculateSum()

    MySumLabel.Text = (TotalValueIncVatLabel.text - DepositTextbox.text - StagepayementTextbox.text - BalanceTextbox.text)

    end sub

    and on the change even of each of the textboxes call this procedure.

  • jimmsl

     DMan1 wrote:
    If these values are bound to a label or textbox on your form then you could do something like this....

    MySumLabel.Text = (TotalValueIncVatLabel.text - DepositTextbox.text - StagepayementTextbox.text - BalanceTextbox.text)

    If you have option explicit turned on (which is a good idea) then you have to explicitly convert each value:

    Dim Result as Double= Convert.ToDouble(TotalValueIncVatLabel.text )- Convert.ToDouble(DepositTextbox.text) - Convert.ToDouble(StagepayementTextbox.text) - Convert.ToDouble(BalanceTextbox.text)

    MySumLabel.Text=Result.ToString


    Dman,

    The values are bound to a textbox, which pulls its data from an access backend.
    So im going to go down the MysumLabel route.

    Im assuming this is actual VB code that I input in the code view section for the new unbound text box.

    Sorry to sound dumb, but im new to this.
    Not sure where exactly I input this
    Below is the code my unbound text box produces

    Private Sub TextBox7_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox7.TextChanged

    End Sub

    So im assuming I need to add to make this

    Private Sub TextBox7_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox7.TextChanged

    MySumLabel.Text = (TotalValueIncVatLabel.text - DepositTextbox.text - StagepayementTextbox.text - BalanceTextbox.text)

    End
    Sub







  • DccRajesh

    Hi guys,

    Thanks for the info.
    Looking into what you have both said, and will try and implement and get working.

    Many thanks for the responce, and once I have tried this, i`ll report back and let you know how ive got on, or not Big Smile

    Best Wishes
    Max

  • MrBillFromOverTheHill

    There are a couple of different reasons why you may be seeing dup data...

    1.  if you are using a multi-join query you can get dup info

    or

    2.  If you fill your dataset and then fill it again without clearing you will have dup records.



  • kawingxp

    Dman,

    Thanks for the info.
    I posted my report back in the wrong thread.
    Pillock - lol
    Im moving me datagrid bit to my other thread.
    http://forums.microsoft.com/msdn/ShowPost.aspx PostID=65690
    Im going to look into the question in this thread later on today ( the calculation bit)
    Thanks for the reply.


    Max

  • numeric calculations problems