Results 1 to 5 of 5

Thread: Changing value of a label

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2001
    Location
    CT
    Posts
    124

    Cool Changing value of a label

    OK say I have a label that is currently containing a value C102
    but I want to extract that data Add 1 to it so it is now C103.

    I would probably want to take only the 2-4 char's of the label which are number, and do 102+1 = 103 and then do label = "C" & (new value(103))

    How would I go about doing that, I'm a little rusty when it comes to doing this.


    even pointing me in right direction might help me remember the code.

    Thanks
    Vini, Vidi, Vici!
    -----------------
    say this 5 times fast
    "I am not a pheasant plucker, I'm a pheasant plucker's son. I'm only plucking pheasants, till the pheasant plucker comes."

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    VB Code:
    1. Private Sub Command2_Click()
    2.     Label1.Caption = "C" & Val(Mid(Label1.Caption, 2, Len(Label1.Caption) - 1)) + 1
    3. End Sub

    that was ugly coding
    -= a peet post =-

  3. #3
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    VB Code:
    1. Label1.Caption = "C" & Format(Mid(Label1.Caption, 2) + 1)
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  4. #4
    Addicted Member
    Join Date
    Mar 2000
    Location
    Suffolk. UK
    Posts
    162
    ...and that was one of a few I could have answered...

    ...........if only I was faster


  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jun 2001
    Location
    CT
    Posts
    124

    Wink

    Thanks, it was the Val command that I was trying to remember, It works, I remember you could set it up with left, mid, right I think. But Thanks again.
    This is why I love this place quick responses.
    Vini, Vidi, Vici!
    -----------------
    say this 5 times fast
    "I am not a pheasant plucker, I'm a pheasant plucker's son. I'm only plucking pheasants, till the pheasant plucker comes."

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