User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 392,068 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,246 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser:
Views: 899 | Replies: 4
Reply
Join Date: Jan 2008
Posts: 24
Reputation: suganzeni is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
suganzeni suganzeni is offline Offline
Newbie Poster

VB.NET Label box + Timer

  #1  
Mar 25th, 2008
Hi all

Hi to move a label box from left to right and right to left with the help of timers.
Also how to change the fore color of the label (RAndom colcors )with the help of timers

Thanks in advance
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2008
Posts: 43
Reputation: Alekhan is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 4
Alekhan Alekhan is offline Offline
Light Poster

Re: VB.NET Label box + Timer

  #2  
Mar 25th, 2008
drag a timer on your form and a label double click on timer and you will have its event where you need to code.
now put one loop and condition in which you will define Left Position of Label and by condition you will check if label left position is 0 then move to right. That is all the theme behind your code. Plz try to code and if it doesnt work then send me the code at my email [email removed as per forum rules]
Last edited by WolfPack : Mar 25th, 2008 at 10:20 am.
Reply With Quote  
Join Date: Jul 2008
Posts: 4
Reputation: sharrmee is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sharrmee sharrmee is offline Offline
Newbie Poster

Re: VB.NET Label box + Timer

  #3  
33 Days Ago
Hi all

Hi to move a label box from left to right and right to left with the help of timers.
Also how to change the fore color of the label (RAndom colcors )with the help of timers

Thanks in advance[/quote]

Hi all

Hi to move a label box from left to right and right to left with the help of timers.
Also how to change the fore color of the label (RAndom colcors )with the help of timers

Thanks in advance[/quote]


Hi all

Hi to move a label box from left to right and right to left with the help of timers.
Also how to change the fore color of the label (RAndom colcors )with the help of timers

Thanks in advance[/quote]
Reply With Quote  
Join Date: Feb 2008
Location: Sivakasi, Tamilnadu, India
Posts: 366
Reputation: selvaganapathy is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 61
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Whiz

Re: VB.NET Label box + Timer

  #4  
32 Days Ago
Use Rnd () function to Get the Random value.
The Rnd function returns a value less than 1, but greater than or equal to zero.

Example
Dim value As Integer = CInt(Int((256 * Rnd())))

You will get the value 0 to 255
By using Rnd() in timer, generate Color from Color.FromArgb() function and Set this for forecolor
KSG
Reply With Quote  
Join Date: Dec 2002
Location: West Virginia
Posts: 369
Reputation: waynespangler is on a distinguished road 
Rep Power: 6
Solved Threads: 34
waynespangler waynespangler is offline Offline
Posting Whiz

Re: VB.NET Label box + Timer

  #5  
32 Days Ago
Try this:
Public Class Form1
    Dim RanNum As New Random            ' Random number generator
    Dim DistMove As Integer = 10        ' The distance the label moves each time

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        ' Add distance to label
        Label1.Left += DistMove
        ' Check if label has reach the right side of window
        If Label1.Left + Label1.Width > Me.ClientRectangle.Width Then
            ' If so make sure none is hidden
            Label1.Left = Me.ClientRectangle.Width - Label1.Width
            ' Reverse the direction - if positive make negative, if negative make positive
            DistMove = Not DistMove
        ElseIf Label1.Left < 0 Then
            ' If label is less than zero make it zero
            Label1.Left = 0
            ' Reverse the direction
            DistMove = Not DistMove
        End If
        ' Change the forecolor of the label. The RanNum.Next gives a number between 0 and 255
        Me.Label1.ForeColor = Color.FromArgb(255, RanNum.Next(0, 255), RanNum.Next(0, 255), RanNum.Next(0, 255))
    End Sub
End Class
Wayne

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb VB.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 11:55 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC