Label Problem.... (Please)


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 12 of 12

Thread: Label Problem.... (Please)

  1. #1
    Craig Clearman Guest

    Re: Label Problem.... (Please)

    Jay,

    >Well it works!
    >
    >Can you explain... -= and why -= works and
    >
    >label.left = val(label.left) - 1 does not


    Truthfully, I never responded to this because I was never able to replicate
    the problem.

    I assume, though, that the above is not really your code. That won't compile
    under Option Strict. I did remove option strict from my project, and ran the
    code, but I was never able to get it to reset to 0.

    Sorry.

    But there really should never be a difference between -= and x = x - 1

    Ciao, Craig


  2. #2
    Jay King Guest

    Label Problem.... (Please)

    I have a label on a form.

    I have a timer set at 50

    The problem...

    In the timer I have Display_lbl.Left = Val(Display_lbl.Left) - 1

    Display_lbl is the label

    Now...... I want the label to slowly move pixel by pixel out of view sliding
    slowing into the left side of the form (If the Labels initial Left property
    is 0).

    For some CRAZY reasont after moving the label back so far the label resets
    itself to Left = 0. Is there away that I can override this? In VB6 this
    didnt happen and to be frank I think this is Big Brother microsoft taking
    control from me.




  3. #3
    Jacob Grass Guest

    Re: Label Problem.... (Please)

    Jay-

    Here is how I just accomplished what you are trying to do. In the Form
    Constructor, put Timer1.Start. Then, in the Timer1_Tick event, put

    Label1.Left -= 1
    If Label1.Left = -(Label1.Width) Then
    Timer1.Stop
    End If

    Works like a charm for me. . .

    Is there something else you are trying to accomplish that I am not seeing?
    To verify that the timer has stopped, you can add Me.Text = "Timer Stopped"
    after the Timer1.Stop command. . .

    HTH

    Jacob





    "Jay King" <pggoldpg@hotmail.com> wrote in message
    news:3b782a89@news.devx.com...
    > I have a label on a form.
    >
    > I have a timer set at 50
    >
    > The problem...
    >
    > In the timer I have Display_lbl.Left = Val(Display_lbl.Left) - 1
    >
    > Display_lbl is the label
    >
    > Now...... I want the label to slowly move pixel by pixel out of view

    sliding
    > slowing into the left side of the form (If the Labels initial Left

    property
    > is 0).
    >
    > For some CRAZY reasont after moving the label back so far the label resets
    > itself to Left = 0. Is there away that I can override this? In VB6 this
    > didnt happen and to be frank I think this is Big Brother microsoft taking
    > control from me.
    >
    >
    >




  4. #4
    Jay King Guest

    Re: Label Problem.... (Please)

    Well it works!

    Can you explain... -= and why -= works and

    label.left = val(label.left) - 1 does not




  5. #5
    Jacob Grass Guest

    Re: Label Problem.... (Please)

    -= 1 simply decrements the value by 1. Just like += 1 increments the value
    by 1. . . I imagine that the problem you were seeing was that you weren't
    stopping the timer? I don't know really. Your method works for me also.
    You may be reaching the lower limit of the integer? I cannot reproduce the
    behavior you are seeing. . .

    Jacob


    "Jay King" <pggoldpg@hotmail.com> wrote in message
    news:3b7848b2@news.devx.com...
    > Well it works!
    >
    > Can you explain... -= and why -= works and
    >
    > label.left = val(label.left) - 1 does not
    >
    >
    >




  6. #6
    Craig Clearman Guest

    Re: Label Problem.... (Please)

    Wrong month. Sorry.

    Ciao, Craig


  7. #7
    Jay King Guest

    Re: Label Problem.... (Please)

    Hre is my actual code, the idea is still the same, take a label and move it
    to the left untill its completely out of view. ONly now once its out of
    view move it all the way to the right and scroll left.

    Ran is Boolean and is public


    Private Sub Scroll_Tick(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles Scroll.Tick
    If Ran = False then
    Display_lbl.Visible = False
    Display_lbl.Left = Val(Display_lbl.Left + Display_lbl.Width)
    Display_lbl.Visible = True
    Ran = True
    Else:
    If X = Val(Display_lbl.Width) Then
    X = 0
    Ran = False
    Else:
    Display_lbl.Left -=1'= Val(Display_lbl.Left) - 1
    X = X + 1
    End If
    End If
    End Sub



  8. #8
    Jay King Guest

    Re: Label Problem.... (Please)

    I fiured this out...



  9. #9
    Bob Butler Guest

    Re: Label Problem.... (Please)

    "Jay King" <pggoldpg@hotmail.com> wrote in message
    news:3b788a2d@news.devx.com...
    > Hre is my actual code, the idea is still the same, take a label and move

    it
    > to the left untill its completely out of view. ONly now once its out of
    > view move it all the way to the right and scroll left.

    <cut>
    > Display_lbl.Left = Val(Display_lbl.Left + Display_lbl.Width)


    Just out of curiousity, is there any reason to take the Left and Width
    properties and run them through the Val function? All that seems to do is
    convert the Int32 values to a Double and generate extra work. You should
    ony need Val when dealing with String data.




  10. #10
    Jay King Guest

    Re: Label Problem.... (Please)

    No not really, I'm afraid im stuck in the VB6 way of doing things heh.



  11. #11
    Phil Weber Guest

    Re: Label Problem.... (Please)

    > I'm afraid I'm stuck in the VB6 way of doing things heh.

    Jay: I don't think you need Val in VB6, either. The following should work
    fine in VB6 and VB.NET:

    With Display_lbl
    .Left = .Left + .Width
    End With

    ---
    Phil Weber



  12. #12
    Jay King Guest

    Re: Label Problem.... (Please)

    Oh yes thats true what I meant by that comment was, that in some casses
    value 0 would be returned as nohting and you need val to induce the zero. I
    made habbit of it to ensure I would cut down on mistakes.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center