Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old September 9th, 2004, 09:48 PM
wjarrett's Avatar
wjarrett wjarrett is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Idaho
Posts: 68 wjarrett User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 17 sec
Reputation Power: 4
Question Make text flash different colors using vba

I need to make the text on a command button change colors to grab the users attention.

I have tried using if then else statements and For next loops but am not having much success. What I want the code to do is make the text change colors every second.

----------Example code---------------

Dim intTime As Integer

Command194.Visible = True
Command194.SetFocus

For intTime = 10000 to 1 Step -1

If intTime =< 10000 Then
Command194.ForeColor = 2535

ElseIf intTime =< 9000 Then
Command194.ForeColor = 0

ElseIf intTime =< 8000 Then
Command194.ForeColor =2535

ElseIf intTime =< 7000 Then
Command194.ForeColor = 0

ElseIf intTime =< 6000 Then
Command194.ForeColor = 2535

ElseIf intTime =< 5000 Then
Command194.ForeColor = 0

ElseIf intTime =< 4000 Then
Command194.ForeColor = 2535

ElseIF intTime =< 3000 Then
Command194.ForeColor = 0

ElseIf intTime =< 2000 Then
Command194.ForeColor = 2535

ElseIf intTime =< 1000 Then
Command194.ForeColor = 0

ElseIf intTime =< 1 Then
End If

Next intTime
------------------------------------

From what I understand, the computer counts in milliseconds meaning the value 1000 = 1 second.

What I'm trying to do is get the computer to count down from 10000 (i.e. 10 seconds) and alternate the text color from black to red simulating a flashing appearance. The interval between the color changes should be one second.

I haven't programmed in 20 years and am pretty lost when it comes to VBA. It's a lot like Basic and yet Not like Basic.

Anybody got a moment to explain what I'm doing wrong?

Reply With Quote
  #2  
Old September 10th, 2004, 10:34 AM
wjarrett's Avatar
wjarrett wjarrett is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Idaho
Posts: 68 wjarrett User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 17 sec
Reputation Power: 4
Talking Never Mind Guys, I fiured it out

I made two pictures in Paint of the text I wanted displayed one in red one in blue . I then used used them as pictures for the command button and had it cycle back and forth between them. It was kind of the long way around but it worked great.

SubForm Load()
Me.TimerInterval = 1000
End Sub

SubForm Timer()
Static intflash As Integer
If intflash Then
Me!CmdBtnName.Picture = "AddressandNameofPicture # 1 toDisplay"
Else
Me!CmdBtnName.Picture = "AddressandNameofPicture # 2 toDisplay"
End If
intflash = Not intflash
End Sub

This code cycles between picture one and picture two every second giving the appearance that the text is flashing.

----------------------------------------

Quote:
Originally Posted by wjarrett
I need to make the text on a command button change colors to grab the users attention.

I have tried using if then else statements and For next loops but am not having much success. What I want the code to do is make the text change colors every second.

----------Example code---------------

Dim intTime As Integer

Command194.Visible = True
Command194.SetFocus

For intTime = 10000 to 1 Step -1

If intTime =< 10000 Then
Command194.ForeColor = 2535

ElseIf intTime =< 9000 Then
Command194.ForeColor = 0

ElseIf intTime =< 8000 Then
Command194.ForeColor =2535

ElseIf intTime =< 7000 Then
Command194.ForeColor = 0

ElseIf intTime =< 6000 Then
Command194.ForeColor = 2535

ElseIf intTime =< 5000 Then
Command194.ForeColor = 0

ElseIf intTime =< 4000 Then
Command194.ForeColor = 2535

ElseIF intTime =< 3000 Then
Command194.ForeColor = 0

ElseIf intTime =< 2000 Then
Command194.ForeColor = 2535

ElseIf intTime =< 1000 Then
Command194.ForeColor = 0

ElseIf intTime =< 1 Then
End If

Next intTime
------------------------------------

From what I understand, the computer counts in milliseconds meaning the value 1000 = 1 second.

What I'm trying to do is get the computer to count down from 10000 (i.e. 10 seconds) and alternate the text color from black to red simulating a flashing appearance. The interval between the color changes should be one second.

I haven't programmed in 20 years and am pretty lost when it comes to VBA. It's a lot like Basic and yet Not like Basic.

Anybody got a moment to explain what I'm doing wrong?

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Make text flash different colors using vba


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway