Results 1 to 4 of 4

Thread: text and numbers

  1. #1
    Guest

    Post

    How do I? I have two fields in a table, field#1 (2)and field#2 (4)They both have a datatype of text. However when i want to add or substract the values of these two fields together in field#3(data type number) i get an error. How can i get around this problem.

    ie.. i get 2 + 4 = 24 I SHOULD GET 2 + 4 = 6

    i realize that i can't add two text values together. I would need to convert the text values into numbers.

  2. #2
    Hyperactive Member
    Join Date
    Feb 2000
    Posts
    284

    Post

    Use the expression Val or CInt -

    total = Val(txtOne) + Val(txtTwo)

  3. #3
    Lively Member
    Join Date
    Mar 2000
    Posts
    82

    Post

    try cint(field#1) + cint(field2) = field3

    because field1 and field2 are text adding them together is like combining them - thus 2 + 4 = 24, 4 + 2 = 42

  4. #4
    Member
    Join Date
    Jan 2000
    Location
    Singapore
    Posts
    59

    Post

    Hai,
    Since your datatype is text you can not add just like that.
    You should convert into interger or double.
    so before your calcultation you convert into interger if your values are in the integer limit.use Cint function.
    If not simply use Val function.it will converts into double.or use CDbl function.


    thanks
    karun

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