|
-
Jan 20th, 2008, 01:52 PM
#1
Thread Starter
Lively Member
Flashing back ground ?
I have tried to develop and application that enable a background to flash in each second, I wanted to use a counter to count up from I=1 to 100 if 'I' is odd then the background color should be red, if 'I' is even, the background color should be green.
but the problem is, I could not find the code related to the integer parity...
any help would be appreciated
Thank you
-
Jan 20th, 2008, 01:53 PM
#2
Re: Flashing back ground ?
Use teh Mod operator. Use your counter variable with it and if the result is 0 then flash one color and if is 1 then flash the other color.
Are you using a timer control too?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 20th, 2008, 01:56 PM
#3
Thread Starter
Lively Member
Re: Flashing back ground ?
the following is the code I have tried to use
Option Explicit
Dim I As Integer
Private Sub FlashButton_Click()
For I = 1 To 10 Step 1
If Parity(I) = odd Then 'the code of this line is wrong need the right one
FlashButton.BackColor = vbGreen
End If
If Parity(I) = even Then 'the code of this line is wrong need the right one
FlashButton.BackColor = vbRed
End If
Next I
End Sub
-
Jan 20th, 2008, 01:59 PM
#4
Thread Starter
Lively Member
Re: Flashing back ground ?
 Originally Posted by RobDog888
Use teh Mod operator. Use your counter variable with it and if the result is 0 then flash one color and if is 1 then flash the other color.
Are you using a timer control too?
I have tried the timer previously but I could not find a way to work it out
could you please re-explain with more details what you have stated?
-
Jan 20th, 2008, 02:03 PM
#5
Thread Starter
Lively Member
Re: Flashing back ground ?
 Originally Posted by RobDog888
Use teh Mod operator. Use your counter variable with it and if the result is 0 then flash one color and if is 1 then flash the other color.
Are you using a timer control too?
I wanted the background to flash in each second ! each second it swaps the color
-
Jan 20th, 2008, 02:05 PM
#6
Re: Flashing back ground ?
Code:
Option Explicit
Private Sub Command1_Click()
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Static iCount As Integer
iCount = iCount + 1
If iCount = 10 Then Timer1.Enabled = False 'Flash for 10 secods
If iCount Mod 2 = 1 Then
'Flash code first color
Else
'flash code other color
End If
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 20th, 2008, 02:07 PM
#7
Re: Flashing back ground ?
 Originally Posted by M C Benzerari
I wanted the background to flash in each second ! each second it swaps the color
Um, well you need a different color to make the background flash. It needs to change between one color and another in order to provide you a "flash" effect.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 20th, 2008, 02:15 PM
#8
Re: Flashing back ground ?
 Originally Posted by M C Benzerari
I wanted the background to flash in each second ! each second it swaps the color
If timer is set to 1000, how about,
Private Sub Timer1_Timer()
Static flipflop As Integer
flipflop = Not flipflop
If flipflop Then
Form1.BackColor = vbRed
Else
Form1.BackColor = vbYellow
End If
End Sub
-
Jan 20th, 2008, 02:17 PM
#9
Re: Flashing back ground ?
The timer1 event procedure will fire every 1000 ms which is every second.
The code will change from one color to another every second.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 20th, 2008, 02:26 PM
#10
Thread Starter
Lively Member
Re: Flashing back ground ?
Thanks all for the reply I will try your code and let you know very soon today...
-
Jan 20th, 2008, 02:36 PM
#11
Thread Starter
Lively Member
Re: [resolved] Flashing background ?
Thanks Rob your code works OK
-
Jan 20th, 2008, 02:44 PM
#12
Thread Starter
Lively Member
Re: [Resolved] Flashing back ground ?
Thanks Edgemeal your code as well worked OK
I have spent 3 days looking to do so finally VB Forum is really a wonderful rescuer
-
Jan 20th, 2008, 03:02 PM
#13
Thread Starter
Lively Member
Re: Flashing back ground ?
But why the 'flashing' start straight forward after the form is launched in design time, I wanted it to start when I click on button ?
-
Jan 20th, 2008, 03:06 PM
#14
Thread Starter
Lively Member
Re: [resolved] Flashing back ground ?
 Originally Posted by M C Benzerari
But why the 'flashing' start straight forward after the form is launched in design time, I wanted it to start when I click on button ?
I found it I have to add the following code to form code:
Timer1.Enabled = False
it is done
-
Jan 20th, 2008, 04:41 PM
#15
Re: Flashing back ground ?
Cool, we are glad to have helped.
Ps, dont forget to Resolve your thread from the Thread Tools menu so others know its solved.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
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
|