vb.net - Visual Basic setting a global variable making my code DRY -
How can I customize my code to make it a dry approach? So I want to make my variables to be public / general I can use it again
public class BasicForm retarded product 1, PRODUCT2, Product3, Integer Dim firstName, lastName String Private Sub btn_getValue_Click as (ByVal in as the System.Object, ByVal e System.EventArgs) handles btn_getValue.Click 'set variable' product 1 = val (tx_productfield1.Text) PRODUCT2 = val (tx_productfield2.Text) as calculate Product3 = val (tx_productfield3.Text) '' tx_totalValue.Text = product 1 + PRODUCT2 + Product3 end Sub end class
May include anywhere and variable (product 1, PRODUCT2) that I set it once and want to move can easily reach other control I set alway variables to every control what I did before.
Please advise.
Thank you!
I'm not sure I get your question, because you're working in a classroom Am right, but do you know your variables are variable variables?
Your "product" variable should be a private example, or public property. If you use personal examples, then tell a way to reach variables, say a garter method otherwise the "property" is just fine.
public class basic form Public Function getProduct1 () 'Back to product 1 end function as integer ... different recipients at private product 1 integer as personal product 2 Personal Products 3 rounds As the end class
Comments
Post a Comment