|
-
Apr 19th, 2013, 04:35 PM
#1
Thread Starter
Lively Member
Move Object Left
I want my lbl to move to the left every tick but I want the new number to be centered.
Code:
Code:
Public Class frmGame
Dim Rand As Random = New Random
Dim BallNumber As Integer
Private Sub BingoTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BingoTimer.Tick
Dim x As Integer = (Me.ClientRectangle.Width / 2) - (lblNumber.Text.Length + BallNumber.ToString.Length)
BallNumber = Rand.Next(1, 100)
lblNumber.Text = lblNumber.Text + " " + BallNumber.ToString
lblNumber.Location = New Point(x, lblNumber.Location.Y)
End Sub
Private Sub frmGame_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
BingoTimer.Start()
End Sub
End Class
Basicly I need to get my x value to only move left.
-
Apr 19th, 2013, 05:29 PM
#2
Thread Starter
Lively Member
Re: Move Object Left
Got this so far but keeps showing system.genric list etc. Likely would work if the list only displayed the values and not everything else.
Code:
Public Class frmGame
Dim Rand As Random = New Random
Dim BallNumber As Integer
'Bingo List
Private Numbers As List(Of Integer)
Private Sub BingoTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BingoTimer.Tick
'Current BallNumber
Dim xC As Integer = (Me.Width / 2) + (BallNumber.ToString.Length / 2)
'Previous BallNumber
Dim xP As Integer = (lblCurrentNumber.Location.X - lblPreviousNumber.Text.Length)
'Ball Numbers
BallNumber = Rand.Next(1, 100)
'Text
lblCurrentNumber.Text = BallNumber.ToString
lblPreviousNumber.Text = Numbers.ToString
'Location
lblCurrentNumber.Location = New Point(xC, lblCurrentNumber.Location.Y)
lblPreviousNumber.Location = New Point(xP, lblPreviousNumber.Location.Y)
'Add Numbers
Numbers.Add(BallNumber)
End Sub
Private Sub frmGame_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Initialize List
Numbers = New List(Of Integer)
'Start Timer
BingoTimer.Start()
End Sub
End Class
-
Apr 19th, 2013, 05:39 PM
#3
Thread Starter
Lively Member
Re: Move Object Left
Kinda working:
Code:
Public Class frmGame
Dim Rand As Random = New Random
Dim BallNumber As Integer
'Bingo List
Private Numbers As List(Of Integer)
Private Sub BingoTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BingoTimer.Tick
'Current BallNumber
Dim xC As Integer = (Me.Width / 2) + (BallNumber.ToString.Length / 2)
'Previous BallNumber
Dim xP As Integer = (lblCurrentNumber.Location.X - lblPreviousNumber.Text.Length)
'Ball Numbers
BallNumber = Rand.Next(1, 100)
'Text
lblCurrentNumber.Text = BallNumber.ToString
lblPreviousNumber.Text = Numbers.ToString
'Location
lblCurrentNumber.Location = New Point(xC, lblCurrentNumber.Location.Y)
lblPreviousNumber.Location = New Point(xP, lblPreviousNumber.Location.Y)
'Add Numbers
Numbers.Add(BallNumber)
'Loop
For Each number As String In Numbers
lblPreviousNumber.Text = lblPreviousNumber.Text & " " & number
Next
End Sub
Private Sub frmGame_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Initialize List
Numbers = New List(Of Integer)
'Start Timer
BingoTimer.Start()
End Sub
End Class
-
Apr 20th, 2013, 12:58 AM
#4
Re: Move Object Left
Did you want the numbered text to be centered in the label as it is moving? What exactly are you trying to achieve?
-
Apr 20th, 2013, 10:11 AM
#5
Thread Starter
Lively Member
Re: Move Object Left
I got it working thanks for helping.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|