Solved

Endless Looping of your name..with changing of Font color

Posted on 2012-04-09
7
40 Views
Last Modified: 2016-06-23
I'm trying to make is so that a Name located in lblName...will be continually changing the color of the Font Letter  in 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..

What am i doing wrong here...? should I have have

 For Num > 4 Then Num = 0
        Me.lbl.Name = MyColors(Num)

Here is the code...hopefully somebody can help


Public Class Form1
    Dim MyColors(2) As Color 'Global
    Dim Num As Integer 'Global, automatically initialized to 0

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As  _
            System.EventArgs) Handles MyBase.Load
        MyColors(0) = Color.Red
        MyColors(1) = Color.White
        MyColors(2) = Color.Blue
        MyColors(3) = Color.Purple
        MyColors(4)= Color.Orange
    End Sub 'Form1_Load

    Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As  _
            System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
        Num = Num + 1
         IF Num > 4 Then Num = 0
        Me.lbl.Name = MyColors(Num)
     
    End Sub 'Form1_MouseClick
End Class
0
Comment
Question by:annie8508
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
7 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 37823776
this line:
Dim MyColors(2) As Color 'Global

should read:
Dim MyColors(4) As Color 'Global
0
 
LVL 45

Expert Comment

by:aikimark
ID: 37823949
You can also use modular division to loop the index through the five color values.
Example:
Num = (Num +1) Mod 5

Open in new window

0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37832955
Change

IF Num > 4 Then Num = 0

to

IF Num >=0 4 Then Num = 0
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 41667596
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question