• computation on controls or variables (VB.NET)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » computation on controls or variables (VB.NET)

    Author
    Topic
    #410225

    I would like to know besides it is more efficient, is there any other reason to perform computations on variable instead of on controls directly?

    Viewing 4 reply threads
    Author
    Replies
    • #879929

      Depending on what you are doing of course? But if you are doing complicated computations, you would probably create a seperate function or subroutine for the calculation, in this case, you may pass a variable representing the value to be manipulated, rather than a control that contains the value. By doing this, you make your function more re-usable, as it relies only on the data type to be the same (ie. string), and not a particular control type (such as a value from a combo box, or text box, or list box).

      Also, it can make the code more obvious as to what you are doing if you are doing calculations on a variable. It may make the code more readable?

      Just some thoughts.

    • #879930

      Depending on what you are doing of course? But if you are doing complicated computations, you would probably create a seperate function or subroutine for the calculation, in this case, you may pass a variable representing the value to be manipulated, rather than a control that contains the value. By doing this, you make your function more re-usable, as it relies only on the data type to be the same (ie. string), and not a particular control type (such as a value from a combo box, or text box, or list box).

      Also, it can make the code more obvious as to what you are doing if you are doing calculations on a variable. It may make the code more readable?

      Just some thoughts.

    • #879963

      Your question is a bit vague. Are you talking about repeatedly referencing a control in a code routine, or what? There is also a board in the Lounge specifically for VB.Net, and you might be better off posting your VB.Net questions there rather than here.

    • #879964

      Your question is a bit vague. Are you talking about repeatedly referencing a control in a code routine, or what? There is also a board in the Lounge specifically for VB.Net, and you might be better off posting your VB.Net questions there rather than here.

    • #880176

      > I would like to know besides it is more efficient, is there any other reason to perform computations on variable
      > instead of on controls directly?

      Fewer changes when you want to re-use your code in another project with differently named controls?

    Viewing 4 reply threads
    Reply To: Reply #879963 in computation on controls or variables (VB.NET)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel