Labels

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OuTCasT
    Contributor
    • Jan 2008
    • 374

    Labels

    Hi
    I would just like to know how i would limit a labels character to a maximum of 6 ???
    I have a calculation that brings a result into a label but now the full answer is displayed, which wld be like 21.256545865896 6 and i would like to only have the first 6 characters, 21.25

    something like that
  • devonknows
    New Member
    • Nov 2006
    • 137

    #2
    Originally posted by OuTCasT
    Hi
    I would just like to know how i would limit a labels character to a maximum of 6 ???
    I have a calculation that brings a result into a label but now the full answer is displayed, which wld be like 21.256545865896 6 and i would like to only have the first 6 characters, 21.25

    something like that
    One way for you to do that, is convert it to a single, you will get about 8 characters from the example you gave above,
    [code=vb]
    dim Result as single
    Result = 21.256545865896 6
    Result = csngl(Result) '// Result for This = 21.25655
    MyLabel.Caption = Result

    [/code]
    Or you can cut the length via the Left$ sub
    [code=vb]
    dim Result as Double
    Result = 21.256545865896 6
    '//Change the Number 6 below for different legnths
    MyLabel.Caption = Left$(Result, 6) '//Result for this shows 21.256
    [/code]
    I hope this helps you
    Kind Regards
    Devon

    Comment

    • OuTCasT
      Contributor
      • Jan 2008
      • 374

      #3
      Originally posted by devonknows
      One way for you to do that, is convert it to a single, you will get about 8 characters from the example you gave above,
      [code=vb]
      dim Result as single
      Result = 21.256545865896 6
      Result = csngl(Result) '// Result for This = 21.25655
      MyLabel.Caption = Result

      [/code]
      Or you can cut the length via the Left$ sub
      [code=vb]
      dim Result as Double
      Result = 21.256545865896 6
      '//Change the Number 6 below for different legnths
      MyLabel.Caption = Left$(Result, 6) '//Result for this shows 21.256
      [/code]
      I hope this helps you
      Kind Regards
      Devon

      it says..... Conversion from label.text to single is not allowed

      Comment

      • OuTCasT
        Contributor
        • Jan 2008
        • 374

        #4
        Originally posted by devonknows
        One way for you to do that, is convert it to a single, you will get about 8 characters from the example you gave above,
        [code=vb]
        dim Result as single
        Result = 21.256545865896 6
        Result = csngl(Result) '// Result for This = 21.25655
        MyLabel.Caption = Result

        [/code]
        Or you can cut the length via the Left$ sub
        [code=vb]
        dim Result as Double
        Result = 21.256545865896 6
        '//Change the Number 6 below for different legnths
        MyLabel.Caption = Left$(Result, 6) '//Result for this shows 21.256
        [/code]
        I hope this helps you
        Kind Regards
        Devon

        Hi Devon.
        I got the problem.
        i used variables
        [CODE=vb]DIM v as decimal[/CODE]

        and i changed it to single and now it works fine.

        THanks

        Comment

        • jamesd0142
          Contributor
          • Sep 2007
          • 471

          #5
          Could you not use:

          [code=vbnet]
          label = mid(label,1,6)
          [/code]

          Comment

          • devonknows
            New Member
            • Nov 2006
            • 137

            #6
            Hmm, the difference being ure using a new version of Visual Basic or your in .NET that might be were the confusion came in, apologies for that.

            I hope i offered a breif insight into what you needed
            Kind Regards
            Devon

            Comment

            • OuTCasT
              Contributor
              • Jan 2008
              • 374

              #7
              Originally posted by devonknows
              Hmm, the difference being ure using a new version of Visual Basic or your in .NET that might be were the confusion came in, apologies for that.

              I hope i offered a breif insight into what you needed
              Kind Regards
              Devon

              No you did get me on the right track so it's all good.

              Thanks Devon

              Comment

              • debasisdas
                Recognized Expert Expert
                • Dec 2006
                • 8119

                #8
                Have anyone considered using the Round function.

                Comment

                Working...