|
-
Jun 16th, 2008, 01:37 AM
#1
Thread Starter
Lively Member
How to make a label move
I've read on a few topics abt this in this forum and i have try the source code that have been suggested. Unfortunately it did not work on my project and i do not know why.
[CODE]
Private sub form_load()
ndName = txbFullName
lblUser.Caption = "You are now login as " & ndName
end sub
Private Sub Timer1_Timer()
lblUser.Move lblUser.Left + 1
End Sub[CODE]
-
Jun 16th, 2008, 01:47 AM
#2
Addicted Member
Re: How to make a label move
vb Code:
Private Sub ChangePosition_Click()
Label1.Left = Label1.Left + 100 ' or just place ur own value like label1.left = 500
Label1.Top = Label1.Top + 100 ' or just place ur own value like label1.top = 500
End Sub
that will do the work !!
●════════════════════════════◄►═════════════════════════●
___itš bεttεг tΘ bε απ Θρεπ šiππεг, thαπ α ƒαlšε šαiπt___
●════════════════════════════◄►═════════════════════════●
гαj
-
Jun 16th, 2008, 02:03 AM
#3
Thread Starter
Lively Member
Re: How to make a label move
yeah the label moved but after we press the button can the label scroll vertically itself without stopping when the form load
-
Jun 16th, 2008, 06:04 AM
#4
Re: How to make a label move
Is this what you mean?
Code:
Private Sub Timer1_Timer()
Label1.Caption = ScrollText(Label1.Caption)
End Sub
Private Function ScrollText(MyText As String) As String
'Take the first char of a string and move it to the back.
MyText = (Right$(MyText, Len(MyText) - 1)) & Left$(MyText, 1)
ScrollText = MyText
End Function
-
Jun 16th, 2008, 07:41 PM
#5
Thread Starter
Lively Member
Re: How to make a label move
are we did not call timer in sub form_load?
-
Jun 17th, 2008, 12:57 AM
#6
Addicted Member
Re: How to make a label move
do u mean to move.......... from Title.............. ??
●════════════════════════════◄►═════════════════════════●
___itš bεttεг tΘ bε απ Θρεπ šiππεг, thαπ α ƒαlšε šαiπt___
●════════════════════════════◄►═════════════════════════●
гαj
-
Jun 17th, 2008, 01:12 AM
#7
Thread Starter
Lively Member
Re: How to make a label move
No, no sorry for make this problem complicated but what i want is the label is moving vertically when the form is loaded i have try those source code posted by Hack but it still not working.
-
Jun 17th, 2008, 05:36 AM
#8
Re: How to make a label move
Have you placed a timer control onto your form, is it enabled (can be set via the properties window) and what's it's interval set to (again found under the properties window).
A control can be placed using-
Code:
ControlName.Left= ControlName.left -10 ' will move 10 pixels to the left.
ControlName.Left= ControlName.left +10 ' will move 10 pixels to the right.
ControlName.Top = ControlName.Top -10 ' will move 10 pixels upward.
ControlName.Top = ControlName.Top +10 ' will move 10 pixels downward.
You can test these codes in a button's click event on your form. Placing this into a timer means whenever the timer interval is encountered (i.e. every 100 nanoseconds if it's interval is set to 100), this code will run and say, move the control left. If the timer interval is set low enough, the movement line of code will happen rappidly in succession and give the appearance of the control being animated.
Last edited by alex_read; Jun 18th, 2008 at 01:18 AM.
-
Jun 17th, 2008, 06:33 AM
#9
Re: How to make a label move
 Originally Posted by hiadan_dan
are we did not call timer in sub form_load?
If the timer is enabled, it will begin as soon as the Form is Loaded. You don't have to have any code to activate it.
 Originally Posted by hiadan_dan
No, no sorry for make this problem complicated but what i want is the label is moving vertically when the form is loaded i have try those source code posted by Hack but it still not working.
Did you set the timer interval to something appropriate?
-
Jun 17th, 2008, 07:56 PM
#10
Thread Starter
Lively Member
Re: How to make a label move
the label can move now thanks guy!! , the think is i forgot to put the timer on the form. I have another question whut if after move to the left until it disappear how i want it to start move again from the original place
-
Jun 18th, 2008, 01:17 AM
#11
Re: How to make a label move
Have you played with Private, form level variables before? You want to create a variable right at the top of your VB form, like this:
Code:
Private m_OriginalLabelPos as integer
Then in your form_load event (so after to form and it's controls are instanciated and prior to them rendering on screen or the timer starting), to capture the label's start position, and store it within this variable:
Code:
Private Sub Form_Load()
m_OriginalLabelPos = LabelNameHere.left
End Sub
That's just gone and stored the original value of the left property position of your label, in a variable which can nowbe accessed from within any sub procedure or function in your form -including that of the timer interval passing Timer1_Timer() event.
The next stage is to add an IF statement to this event to check whether the label's left position, plus it's width (giving us it's right position), are less than that of the form's left position. If this is the case, the label is appearing "off-screen" and therefore we reset it to it's original position:
Code:
Private Sub Timer1_Timer()
If CInt(LabelNameHere.left + LabelNameHere.Width) < 85 Then
LabelNameHere.left = OriginalLabelPos
Else
LabelNameHere.Left= LabelNameHere.left -10
End If
End Sub
Last edited by alex_read; Jul 2nd, 2008 at 01:08 AM.
-
Jun 18th, 2008, 08:37 AM
#12
Re: How to make a label move
The label will be in its original place the next time the form is loaded.
If you don't want it to move off the form, then use the Form's Left property as the labels maximum -10 left most position.
-
Jul 1st, 2008, 10:47 PM
#13
Thread Starter
Lively Member
Re: How to make a label move
i have use alex_read source code but the label stuck
on the first place, it did not scroll like the first time it moves. When the label disappear on the left i want it to move back again on the right. Am i have to widen the label box?
-
Jul 2nd, 2008, 01:09 AM
#14
Re: How to make a label move
I've now bought up VS and tested the coding now. Please try the above ammended and tested sample which should get you up and running.
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
|