Page 1 of 1

Blinking Text for Beginners This will help you to create a cool animation(blinking text) for your Rate Topic: ***** 1 Votes

#1 akhileshbc  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 9
  • View blog
  • Posts: 179
  • Joined: 27-September 08

Post icon  Posted 27 September 2008 - 09:59 PM

Hi guys,
Most of you had created many programs for various purpose. But have you ever thought of some animation in your program..:)

Here I am going to mention a small tutorial on creating a blinking text effect. It is for pure beginners.

First of all open the Visual Basic using Start>Programs>Microsoft Visual Studio>Visual Basic 6.0.

Then select Standard EXE and click open.
You will get a blank Form.

From the toolbox(in left side), select Command Button and create two buttons in your form(say, Command1 and Command2).
Also, create a Timer in your form(say, Timer1)

Then open the code window(View menu> View Code).
Then write the code as below:
Private Sub Command1_Click()
Timer1.Interval = 100 'interval of the timer
Timer1.Enabled = True 'starting the animation
Label1.Caption = "Welcome" 'text to display
End Sub

Private Sub Command2_Click()
Timer1.Enabled = False 'stopping the animation
End Sub

Private Sub Form_Load()
Timer1.Enabled = False 'disabling the animation on loading the form
End Sub

Private Sub Timer1_Timer()
If Label1.Visible = True Then 'checking whether it is visible
	Label1.Visible = False 'if visible then, make it invisible
ElseIf Label1.Visible = False Then 'checking whether it is invisible
	Label1.Visible = True 'if invisible then, make it visible
End If
End Sub

I had included most of the comments in the code itself. I think you understand my coding. If you have any doubt, please feel free to contact me....:)

-Akhilesh B Chandran

Is This A Good Question/Topic? 0
  • +

Replies To: Blinking Text for Beginners

#2 gleeenob  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-November 08

Posted 09 November 2008 - 02:52 PM

you messed up on the " Private Sub Form_Load()
Timer1.Enabled = False
End Sub " part but hey w/e
Was This Post Helpful? 0
  • +
  • -

#3 massoud raji  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 20-December 08

Posted 26 December 2008 - 05:29 PM

Dear Sir
Thank you but the following statement is redundant:

If Label1.Visible = False Then 'checking whether it is invisible

This post has been edited by massoud raji: 26 December 2008 - 05:33 PM

Was This Post Helpful? 0
  • +
  • -

#4 rdsrds2120  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 393
  • Joined: 18-December 08

Posted 07 January 2009 - 08:58 PM

Very nice tutorial, now, here is for anyone that wants it to toggle back and forth only using one command button



 Form_Load()
Timer1.Enabled = False
End Sub

Private Sub Command1_Click()
Timer1.Interval = 100
Label1.Caption="Welcome" 'It is OK that it rapplies the interval and caption				
										 
If Timer1.Enabled = True Then 
	 Timer1.Enabled = False 
ElseIf Timer1.Enabled = False Then 
	 Timer1.Enabled = True 
End If



now, be careful for a common If Then mistake that I see in my class. Some people try to put the code
If Timer1.Enabled = True Then
	 Timer1.Enabled = False
End If

If Timer1.Enabled = False Then
	 Timer1.Enabled= True
End If


in place of the ElseIf statment nested in.
The problem with this is when the code is executed if Timer1.Enabled = True, it would become false and then be applied to the next If Then Statement. It is good to learn a very very well understanding of the If Then statement if you are a very beginning programmer.
I free handed this coding so don't get too picky with the ity bity techs like the Private Subs and wahtnot
Was This Post Helpful? 0
  • +
  • -

#5 Dalidar91  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 7
  • Joined: 07-October 09

Posted 15 October 2009 - 10:20 AM

View Postrdsrds2120, on 7 Jan, 2009 - 07:58 PM, said:

Very nice tutorial, now, here is for anyone that wants it to toggle back and forth only using one command button



 Form_Load()
Timer1.Enabled = False
End Sub

Private Sub Command1_Click()
Timer1.Interval = 100
Label1.Caption="Welcome" 'It is OK that it rapplies the interval and caption				
										 
If Timer1.Enabled = True Then 
	 Timer1.Enabled = False 
ElseIf Timer1.Enabled = False Then 
	 Timer1.Enabled = True 
End If



now, be careful for a common If Then mistake that I see in my class. Some people try to put the code
If Timer1.Enabled = True Then
	 Timer1.Enabled = False
End If

If Timer1.Enabled = False Then
	 Timer1.Enabled= True
End If


in place of the ElseIf statment nested in.
The problem with this is when the code is executed if Timer1.Enabled = True, it would become false and then be applied to the next If Then Statement. It is good to learn a very very well understanding of the If Then statement if you are a very beginning programmer.
I free handed this coding so don't get too picky with the ity bity techs like the Private Subs and wahtnot



how does this all work in Microsoft VB 2008 i do not have an older version and the people i work with require me to use it so if you can help me figure out how to make it work in vb 2008 i would be greatly appreciated
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1