Results 1 to 4 of 4

Thread: How to make a button add....??

  1. #1

    Thread Starter
    Lively Member moe222's Avatar
    Join Date
    Sep 2003
    Location
    Canada
    Posts
    68

    How to make a button add....??

    Hello all..
    I was wondering how I can make a click of a button add to the caption of a label..in other words i have a label with caption saying 100 when the button is clicked i want 50 added to the caption, can i do that? And if so how can i make it subtract as well.

    (Sorry for bad english)
    Moe

  2. #2
    try this:

    VB Code:
    1. Private Sub Command1_Click()
    2. 'addition
    3. label1.Caption = val(label1.caption) + 50
    4. 'subtraction
    5. label1.Caption = val(label1.caption) - 50
    6. End Sub
    a 17 year old kid who has nothing better to do !
    and i never said i was right !!!

  3. #3
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    something like this then.....
    VB Code:
    1. Private Sub Command1_Click()
    2. If IsNumeric(Label1.Caption) Then '/// make sure it's only numbers you try to add up.
    3.     Label1.Caption = Label1.Caption + 50
    4. End If
    5. End Sub
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  4. #4

    Thread Starter
    Lively Member moe222's Avatar
    Join Date
    Sep 2003
    Location
    Canada
    Posts
    68

    thx

    thx it worked
    Moe

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