|
-
December 9th, 2015, 10:10 PM
#1
Help with calculations on button click
Not really sure what my problem is but here we go.
Ive created a simple windows form in visual studio to calculate an NPS (Net Promoter Score) average. Everything is finally working with one exception. When I click my calculate button only half of the calculations are done, I have to click it once more to get the code to finish. Im new to vb but it seems to me like the problem is the code is getting ahead of itself and since the end formula needs the results from several of my labels it cant finish. Im sure its a simple fix but I cant quit get it. Any assistance would be much appreciated.
Code:
Private Sub butCalculate_Click(sender As Object, e As EventArgs) Handles butCalculate.Click
Dim detracter As Double
Dim neutral As Double
Dim promoter As Double
Dim total As Double
Dim TOTAL1 As Double
detracter = Double.Parse(lblD.Text)
neutral = Double.Parse(lblN.Text)
promoter = Double.Parse(lblP.Text)
lblD.Text = Val(lblD.Text) + txtDetractor.Text
lblN.Text = Val(lblN.Text) + txtNeutrals.Text
lblP.Text = Val(lblP.Text) + txtPromoters.Text
TOTAL1 = (promoter - detracter) / (promoter + neutral + detracter)
lblTotal.Text = TOTAL1.ToString("P")
lblTotal.Visible = True
lblTotal.Left = (Me.ClientSize.Width / 2) - (lblTotal.Width / 2)
txtDetractor.Text = "0"
txtNeutrals.Text = "0"
txtPromoters.Text = "0"
total = detracter + neutral + promoter
lblT.Text = total.ToString()
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|