How do I optimize my code making it DRY approach. I want to make my variable to be on public/general so i can re-use it
Public Class BasicForm
Dim Product1, Product2, Product3, As Integer
Dim firstName, lastName As String
Private Sub btn_getValue_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_getValue.Click
'Set variables'
Product1 = Val(tx_productfield1.Text)
Product2 = Val(tx_productfield2.Text)
Product3 = Val(tx_productfield3.Text)
'Calculate'
tx_totalValue.Text = Product1 + Product2 + Product3
End Sub End Class
I want to move the variables (product1,product2) to somewhere else that I can set it one time and easily access it with other control. What I did before is I alway set the variables to every control.
Please advice.
Thanks!