Results 1 to 6 of 6

Thread: Using variable or Label

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    Using variable or Label

    Hi guys,

    I take data from Database and then display it using Label and/or Textbox.
    Later i will doing some calculation from that data.
    Please give me some advice for best approach to do calculation as i need.
    Is it using Label/Textbox then convert it to appropriate DataType (Date, Long, Double, Integer, Etc) or best when i take data from DataBase i create variable separately (with appropriate DataType) for each Label/Textbox?

    Sorry for my English

    Thanks.
    Last edited by barianto; Oct 17th, 2006 at 04:46 AM.

  2. #2
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Using variable or Label

    Six of one, half a dozen of another. Depending upon what you need to do with the data you can either use a variable you can set the Data Type when you dimensioned the variable or if you are displaying it you can just as easily change to the necessary data type (i.e, cLng, cStr, etc.)
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    Re: Using variable or Label

    Thanks Mark.

    Any other point of view, people?

  4. #4
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Using variable or Label

    It's better coding practice to store all data in variables (of the appropriate data type), and then display those variables in a label/textbox later.

    This way you always have the data in its correct form in memory and you don't have to convert a label or textbox (string) back into the right data type.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    Re: Using variable or Label

    I have some thought like that too DigiRev.
    But will it suffer (little bit or a lot) performance of our application if we have to many variable? Not to mention if we working with MDI form with no limitation for user to open the same Form.

  6. #6
    Hyperactive Member Bearnerd's Avatar
    Join Date
    Apr 2006
    Location
    Malaysia
    Posts
    290

    Re: Using variable or Label

    Labels and textbox is just a controls you can use to display data from your database. Any calculation can be made using value from label or textbox but it is necessary to convert them into specific datatype using datatype conversion like cstr(), clng() and so on. You can also use data read directly from database by first storing them in variables with appropriate datatype for your calculation like what digirev suggested.

Posting Permissions

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



Click Here to Expand Forum to Full Width