473,513 Members | 2,749 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Endless Looping with Font.Colors in Visual Basic 2010

10 New Member
I'm trying to make is so that a Name located in lblName...will be continually changing the color of the Font Letter in the same order when I click the Form1

So click Form1

The Name will be Red, Click again Name will be in White, Click again Name will be Blue , click again Name will be Purple, click again the Name will be Orange, and the process startes all over again..Color is the same...

What am i doing wrong here...? should I have have
Expand|Select|Wrap|Line Numbers
  1.  For Num > 4 Then Num = 0 
  2.         Me.lblName = MyColors(Num)
Here is the code...hopefully somebody can help

I feel like there's something else missing like
Font.Color or something...


Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Dim MyColors(4) As Color 'Global
  3.     Dim Num As Integer 'Global, automatically initialized to 0
  4.  
  5.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As  _
  6.             System.EventArgs) Handles MyBase.Load
  7.         MyColors(0) = Color.Red
  8.         MyColors(1) = Color.White
  9.         MyColors(2) = Color.Blue
  10.         MyColors(3) = Color.Purple
  11.         MyColors(4)= Color.Orange
  12.     End Sub 'Form1_Load
  13.  
  14.     Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As  _
  15.             System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
  16.         Num =( Num + 1) Mod 5
  17.          IF Num > 4 Then Num = 0 
  18.         Me.lblName = MyColors(Num)
  19.  
  20.     End Sub 'Form1_MouseClick
  21. End Class
Apr 9 '12 #1
1 1977
Monomachus
127 Recognized Expert New Member
Try this.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As  _
  2.             System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
  3.         Num = (Num + 1) Mod 5
  4.         If Num > 4 Then Num = 0
  5.         Me.lblName.ForeColor = MyColors(Num)
  6.  
  7.     End Sub 'Form1_MouseClick
Apr 9 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3891
by: jabailo | last post by:
These guys have it going on. They actually use design ideas that Microsoft employees can drool upon. Visual Studio 2010 Concept IDE http://www.codeproject.com/csharp/Concept_IDE.asp "Like...
16
1437
by: Jesse Liberty | last post by:
I am writing a new book on Visual Basic 2005, targeted at VB6 programmers, and to some degree VB.NET 1.x programmers. I'd like to sign up a (limited) number of volunteers to read the book and...
7
1844
by: gerryLowry::Ability Business Computer Services {KC | last post by:
"Getting Back Your Visual Basic 6.0 Goodies" by Billy Hollis, 2003-5-14, states: "Getting a Forms Collection Visual Basic 6.0 developers are often fond of looping through the currently loaded...
1
950
by: wendy elizabeth 26th | last post by:
I want to setup the presentation layer of a new visual basic.net 1.1 asp.net web application separate from the business logic and the data access layer. The presentation layer needs to have a front...
2
2610
by: trezraven | last post by:
I am creating a template in Word 2007 using Visual Basic Editor. I am pulling information from an Access database. I know this is probably a stupid question, but for the life of me I can't figure out...
4
3069
by: Chris Asaipillai | last post by:
Hi there My compay has a number of Visual Basic 6 applications which are front endeed onto either SQL Server or Microsoft Access databases. Now we are in process of planning to re-write these...
1
1424
by: =?Utf-8?B?RHVzdGlu?= | last post by:
I am trying to build a program for the first time in Visual Basic. I work for a public utility and we will use to track our crews during large outages. It is a simple program with 16 lines of text...
4
5463
by: terry guthrie | last post by:
Hi I am taking a class that involvs visual basic, I have created buttons that when clicked come up in a color, i now need to have them come up in Random colors. here is the formula i have so far. ...
2
3504
by: Johnny Wong | last post by:
Hi, I am new to visual basic. In my vb system, there is a dynamic datagrid to represent different reocrds in our database. Today I am gonna export the data to Excel file. I found most examples code...
0
7259
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7380
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7523
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5683
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5085
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.