Problem with a calulator

Hello, im new here and i have a quick question.

When i make VB do maths like: Label1.Caption = Text1.Text * Text2.Text (or 5*5=25) However if i try Label1.Caption = Text1.Text + Text2.Text i get something like 5+5=55.

How could i make it add up numbers in a text box




Answer this question

Problem with a calulator

  • johnacs

    Int() Attempts to convert the object into a integer

    Same a CDbl() for double, Cbool for boolean, cStr for string... and so on.

    You could also use CType() command to cast objects from one type to another. (When possible.)

    Dustin



  • tolily

    we can use variable and then also we can perform calculation

    for example

    dim a ,b as integer

    a =val(textbox1.text)

    b=val(textbox2.text)

    label1.caption=a*b

    or any operation this



  • Eileen Ewen

    Thankyou very much... what does the *int* do

  • Michael Baxter

    Try

    Label1.Caption = int(Text1.Text) + int(Text2.Text)

    Dustin



  • edwinzzz

    You can also make it this way...

    Label1.caption = val(Text1.text) + val(Text2.text)

    Label1.caption = val(Text1.text) * val(Text2.text)



  • Problem with a calulator