1 Replies - 225 Views - Last Post: 27 October 2017 - 01:55 PM Rate Topic: -----

#1 amck2017  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 30-August 17

trying to turn an input into numeric and how to increase a value

Posted 27 October 2017 - 07:32 AM

I have the created a textbox called grouptextbox once the user enter the name of there group want I it to turn into a number and output into another textbox called numberofgroupbox. And the second problem I have to program to calculate and them return a value into a textbox called totalchargebox,want the value to remain and continue to increase as more groups values are added. So far only the first group value calucalates but as another value is entered it does not add on to the previous value. Don't know if I'm close or not. This may be a simple task for those who read this and would gladly accept any advice

Const _CDECPRICEPERrental As Decimal = 200D
    Private printRecordingstudio As Object
    Private Sub Button5_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ExitButton.Click
        Close()
    End Sub
    Private Sub btnCalculateButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CalculateButton.Click
        'Private Sub Btncalculatecost_Click(sender As Object, e As EventArgs) Handles Btncalculatecost.Click
        'This event handler is executed when the user clicks the 
        'calculate cost button . It calculates and displays the cost
        'of the time rented.(number of times the cost per rental).
        Dim intNumberoftime As Integer
        Dim decTotalCost As Decimal
        Dim TotalChargesInteger, GroupInteger, MinInteger As Integer


        intNumberoftime = MinTextBox.Text
        decTotalCost = intNumberoftime * _CDECPRICEPERrental / 60
        Rentalchargebox.Text = decTotalCost.ToString("C")
        TotalChargesbox.Text = Rentalchargebox.Text



        [color="#48D1CC"]'Convert Input values to numeric variables
        GroupInteger = Integer.Parse(Grouptextbox.Text)
        MinInteger = Integer.Parse(MinTextBox.Text)[/color]
        ' Calculate Value.
        TotalChargesInteger = GroupInteger * MinInteger



    End Sub
:code:

This post has been edited by modi123_1: 27 October 2017 - 07:33 AM
Reason for edit:: In the future, please use the [code] tag button in the editor.


Is This A Good Question/Topic? 0
  • +

Replies To: trying to turn an input into numeric and how to increase a value

#2 IronRazer  Icon User is offline

  • Custom Control Freak
  • member icon

Reputation: 1447
  • View blog
  • Posts: 3,682
  • Joined: 01-February 13

Re: trying to turn an input into numeric and how to increase a value

Posted 27 October 2017 - 01:55 PM

I am not sure if i follow what you are saying but, the lines below are declared inside your btnCalculateButtutton click event sub which makes them Local variables which will only exists inside the sub. So, each time the calculate button is clicked they would be declared again and set back to 0.
        Dim intNumberoftime As Integer
        Dim decTotalCost As Decimal
        Dim TotalChargesInteger, GroupInteger, MinInteger As Integer



If you want one or more of those vaiables to retain their value(s) between each click of your calculate button, then they should be declared at the class scope. A Class scoped variable would be declared outside of any subs or functions but, still inside the Form class. Then they would still have the last value the next time the button is clicked. You can then add to that value.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1