Results 1 to 4 of 4

Thread: Counting

  1. #1

    Thread Starter
    Hyperactive Member Matt-D's Avatar
    Join Date
    Nov 1999
    Location
    Mettmann, Germany
    Posts
    305

    Question

    I have a problem with countig (VB3):
    The caption of Label1 is '3'
    The caption of Label2 is '6'

    I want to add up the two numbers, but VB always
    wirtes 36 instead of 9 with this method:
    Label3.caption = Label1.caption + Label2.caption

    I want that the two numbers are added and I don't
    want to use a text-box.

    Thanks for some advice, Matt-D(eutschland)

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Leavenworth KS USA
    Posts
    482
    Force the weak typecast

    DIM i as integer
    i = Label1.Caption
    i = i + Label2.Caption
    Label3.Caption = i

    or...
    Label3.Caption = CInt(Label1.Caption) + CInt(Label2.Caption)


  3. #3
    Lively Member
    Join Date
    Mar 2000
    Location
    Fort Lauderdale, FL USA
    Posts
    112
    try this

    Label3.caption = Val(Label1.caption) + Val(Label2.caption)


  4. #4

    Thread Starter
    Hyperactive Member Matt-D's Avatar
    Join Date
    Nov 1999
    Location
    Mettmann, Germany
    Posts
    305
    Thanks

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