Consulting

Results 1 to 6 of 6

Thread: label caption

  1. #1

    label caption

    I'm trying to enter a number display in a label into a textbox. For some reason, its entering it as a text. The code I'm using is below. I need to enter the number display in the label into textbox (as a number), so I can enter it into the worksheet. Can someone assist. Thanks

    [VBA]Textbox1.Value = Label16.Caption[/VBA]

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    [VBA][A1]=label16.caption[/VBA]

  3. #3
    forgive me...but what is [A1]?
    Sorry I should have mention, this label and textboxes are on a userform

  4. #4
    ok...I think I discovered the source of the error. this code..

    [vba]Cells(ActiveCell.Row, 95)[/vba]
    is storing the number in the textbox as a text. Its also storing the number into the sheet as a text. So I guess my question, now, is how do I store the value as a number and not a text?

  5. #5
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    [A1]=Range("A1")=Cells(1, 1)

    A caption and a textbox are strings. What is the value of your label caption?

    [VBA]Range("A1").Value = Label16.Caption[/VBA]

    You can use CInt(), CDbl(), CLng(), if you like.

  6. #6
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    You'll have to format cells(j,95) to 'general' (in any case not 'text/string')
    Excel interprets every number automatically as number if you write it into a worksheet, no matter whether is has been presented as a string or not.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •