Results 1 to 10 of 10

Thread: Point A to point B

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2006
    Posts
    19

    Point A to point B

    i am using this
    VB Code:
    1. Dim FirsttoLast As String
    2.         FirsttoLast = Mid(TextToScroll, 1, 1)
    3.         TextToScroll = TextToScroll.Remove(0, 1)
    4.         TextToScroll = TextToScroll.Insert(Microsoft.VisualBasic.Len(TextToScroll), FirsttoLast)
    5.         ScrollingText.Text = TextToScroll

    but how would i scroll it with lenth to it. like from point a to point b.
    Last edited by paperthinstories; Jun 9th, 2006 at 01:42 PM.

  2. #2
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Re: need help

    Quote Originally Posted by paperthinstories
    i am using this
    VB Code:
    1. Dim FirsttoLast As String
    2.         FirsttoLast = Mid(TextToScroll, 1, 1)
    3.         TextToScroll = TextToScroll.Remove(0, 1)
    4.         TextToScroll = TextToScroll.Insert(Microsoft.VisualBasic.Len(TextToScroll), FirsttoLast)
    5.         ScrollingText.Text = TextToScroll

    but how would i scroll it with lenth to it. like from point a to point b.

    ... no clue wat ur trying to do.

    heres a few tips.
    • better title
    • more detail

    (note: this is not a flame. just a suggestion)

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2006
    Posts
    19

    Re: need help

    How would i make a group of text scroll in a label or picture box or anything of that nature sorry for all of the confustion.
    Last edited by paperthinstories; Jun 10th, 2006 at 07:17 AM.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2006
    Posts
    19

    Re: Point A to point B

    hey sorry for all of the confusion about the coding uptop but all i am trying to do is just scroll text in a label.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Point A to point B

    So you're saying that you want a line of text to scroll form one side to the other, correct? If so you could do it by manipulating the text but it will be smoother and easier to actually move the Label. I would add a Panel to the form that was the same Height as your Label and took up the entire Width that you wanted to scroll. I would then start the Label all the way to the Right of the Panel and use a Timer to move it to the Left. Once it gets all the way to the Left you can start again, stop or go back the other way.
    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.     'Start the Label at the far right of the Panel.
    3.     Me.Label1.Left = Me.Panel1.Width
    4.  
    5.     Me.Timer1.Start()
    6. End Sub
    7.  
    8. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    9.     'Move the Label to the left.
    10.     Me.Label1.Left -= 10
    11.  
    12.     If Me.Label1.Right <= 0 Then
    13.         'Start again.
    14.         Me.Label1.Left = Me.Panel1.Width
    15.     End If
    16. End Sub
    You can adjust the Interval of the Timer and the amount you move the Label by each time to make the effect smoother and whatever speed you want.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jun 2006
    Posts
    19

    Re: Point A to point B

    the thing with that i found out is that its not professinal looking it skips . So it i couldnt use it . SO what i did was this ..
    VB Code:
    1. Dim FirsttoLast As String
    2.         FirsttoLast = Mid(texttoscroll, 1, 1)
    3.         texttoscroll = texttoscroll.Remove(0, 1)
    4.         texttoscroll = texttoscroll.Insert(Microsoft.VisualBasic.Len(texttoscroll), FirsttoLast)
    5.         Label1.Text = texttoscroll

    and what that does it it will take one letter at a time and push the other letters further down the line .what im having a problem with is geting the text to scroll the lenth of the label.

    iv tried filling up the label1 with spaces but it doesnt seem to be the right way . so iv just dealt with it .

  7. #7
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Point A to point B

    Here is a solution that smoothly scrolls text similar to above posts. It's in VB6 but can easily be converted.
    http://www.vbforums.com/showpost.php...12&postcount=7
    Another thought is to use GDI+ methods

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Point A to point B

    You've pretty much got three choices with the text itself.

    1. You can manipulate the Text property as you have been.
    2. You can leave the Text property alone and manipulate the Location property as I suggested.
    3. You can use GDI+ to draw the text directly on the form or another control.

    The method of changing the Text itself will be the worst of all because unless you're using a fixed-width font the characters will all be different widths so you will not get an even scroll.

    There is absolutely no reason that the method I suggested should "not look professional" or "skip". Did you do as I suggested and manipulate the Timer's Interval and the amount the Label was moved by? I'm guessing not becuase if you had you would have got a smoother scrolling effect. If you make the Interval and the amount you move the Label by smaller then the effect will get smoother. I just tried it with a Timer Interval of 10 and a Label increment of 1 and it was perfectly smooth. The post moeur links to essentially looks like a more complex version of what I posted earlier.

    GDI+ may be the best method of all as you can simply Invalidate a small portion of the form and have the text redrawn at a new location. If you have no experience with GDI+ you'd have to learn the basics of that, although it's pretty simple.

    Having said all that, you are relying on a Timer to regardless of the method you use. That means that if the UI thread is perfroming some other intensive operation the scrolling effect will suffer because it may not be able to process the Tick events exactly as they are raised. Any significant delaying in handling an event will cause a jerk in the scrolling effect. If your not doing anything else too intensive in the UI thread then you've got no issue.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jun 2006
    Posts
    19

    Re: Point A to point B

    well, i was going to use GUI = system.drawing.text right , stuff of that nature . Iv been trying to learn how to draw text on the form but i couldnt seem to get it to work . if you have any resources for graphic help please send it my way. thanks for the help...

  10. #10
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: Point A to point B

    Take a look at the GDI links in my signature.
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

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