Results 1 to 4 of 4

Thread: Easy one

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343

    Unhappy

    txtItemPrice must be a numeric on my form

    How will I add this to my database or do calculations on it, ensuring that it is saved as numeric and not as text....

    Insert into database....

    insert into client values txtItemPrice

    or

    insert into client values " & txtItemPrice & "

    or

    ???

    Calculations....

    intTotal = txtItemPrice + txtItemVat

    or

    intTotal = "txtItemPrice" + "txtItemVat"

    or

    ????

  2. #2
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    When inserting into your database, if you want it to go in as numeric then use INSERT INTO Client VALUES txtItemPrice.

    When calculating (I'm presuming you're using integers due to what you've call your variable) then you would use the following ...

    Code:
    intTotal = CInt(txtItemPrice.text) + CInt(txtItemVat.text)
    VB6 sp5, SQL Server 2000, C#

    There are no stupid questions. Only stupid people.

  3. #3
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Usually taxes and prices have dollars and cents (or pick you favorite currency and fractinal part, thereof). For that reason, I'd use CCUR instead of CINT

  4. #4
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    I would usually use CCur instead of CCint as well. I only used CInt as turfbults naming of variables indicates that he is using integers.
    VB6 sp5, SQL Server 2000, C#

    There are no stupid questions. Only stupid people.

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