1 Reply Latest reply on Jan 31, 2017 5:26 PM by pthivierge

    Add values in textbox without Dataset


      Hello Everyone,


      I have a several manual input data into Textbox. User can key in the value in respective TextBox.


      Is there any way that we can add (sum) this values in textbox into separate Textbox?


      Currently what i am doing is, when user key in value in textbox, it will uploaded in Dataset then i have to place separately these dataset as a "Value". After that i can add these values which creates a hassle for me. I have a dozens of input data to Textbox


      Is there any simpler way to do this?



        • Re: Add values in textbox without Dataset

          Hello Timur,


          I am not sure if my understanding is correctly but let me try an answer here.


          The idea is to loop over the TextBoxes and to sum the values and finally update the result textbox.

          Name of the controls: input1, input2, result


          The processbook pdi looks like this:


          And here is the code to make the calculation over all textboxes:


          Public Sub SumTextBoxes()
              Dim obj As Symbol
              Dim oText As Object
              Dim valuesSum As Single
              ' This loop will find all Textboxes with a name like input*
              ' End then sum the content and the result will be printed in the result textbox
              For Each obj In ThisDisplay.Symbols
                  ' checking if the object is a multi state
                  If obj.Type = pbSYMBOLTYPE.pbSymbolControl And obj.Name Like "input*" Then
                      Debug.Print obj.Name
                      Set oText = obj.Object
                      valuesSum = valuesSum + Val(oText.Text)
                  End If
              ' update the textbox result
              ThisDisplay.Result.Text = valuesSum
          End Sub


          I have also attached the .pdi file.  (Processbook 2015 R2).


          Please let us know if this helps,

          1 of 1 people found this helpful