Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    computation on controls or variables (VB.NET)

    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?

  2. #2
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: computation on controls or variables (VB.NET)

    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.

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: computation on controls or variables (VB.NET)

    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.
    Charlotte

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: computation on controls or variables (VB.NET)

    > 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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •