Home All Groups Group Topic Archive Search About
Author
13 Jun 2006 2:00 AM
Nedim
first let me say sorry if this is in the wrong place, i'm pretty new to
programming and to be honest i am a bit intimidated by these forums.

now that i've got that out of the way, i was bored and decided to make a
small text application in Visual Basic 2005,

i have one list box, one label and ten buttons.

the list box has 8 colors listed, and when one of them is selected and the
OK button clicked the text in the label changes color, the same with other 8
buttons, but instead of selecting a color from the list the other buttons
change the color of the text directly.

the problem is the tenth button, it's supposed to loop trough all 8 colors,
but it skips directly to the last one (purple) and stays there, the code i
used is this:



        Dim myColor() As Color = {Color.Blue, Color.Red, Color.Green,
Color.Yellow, Color.Black, Color.White, Color.Orange, Color.Purple}

        Dim textcollor As Color
        For Each textcollor In myColor
            Label1.ForeColor = (textcollor)
        Next

Author
13 Jun 2006 3:05 AM
Cowboy (Gregory A. Beamer)
You want to see it scroll through the colors? If so, you need to pause and
paint after each change. Otherwise, it is changing, but not painting until
the entire loop is done. Am I understanding your desire correctly?

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
Show quoteHide quote
"Nedim" <Ne***@discussions.microsoft.com> wrote in message
news:451468DB-7AAD-4DB9-A816-7AFB6121F359@microsoft.com...
> first let me say sorry if this is in the wrong place, i'm pretty new to
> programming and to be honest i am a bit intimidated by these forums.
>
> now that i've got that out of the way, i was bored and decided to make a
> small text application in Visual Basic 2005,
>
> i have one list box, one label and ten buttons.
>
> the list box has 8 colors listed, and when one of them is selected and the
> OK button clicked the text in the label changes color, the same with other
> 8
> buttons, but instead of selecting a color from the list the other buttons
> change the color of the text directly.
>
> the problem is the tenth button, it's supposed to loop trough all 8
> colors,
> but it skips directly to the last one (purple) and stays there, the code i
> used is this:
>
>
>
>        Dim myColor() As Color = {Color.Blue, Color.Red, Color.Green,
> Color.Yellow, Color.Black, Color.White, Color.Orange, Color.Purple}
>
>        Dim textcollor As Color
>        For Each textcollor In myColor
>            Label1.ForeColor = (textcollor)
>        Next
>
>
Author
13 Jun 2006 3:38 AM
Nedim
yes, that is correct, i would like it to scroll trough all the colors i have
set upon pressing the button.

Show quoteHide quote
"Cowboy (Gregory A. Beamer)" wrote:

> You want to see it scroll through the colors? If so, you need to pause and
> paint after each change. Otherwise, it is changing, but not painting until
> the entire loop is done. Am I understanding your desire correctly?
>
> --
> Gregory A. Beamer
>
> *************************************************
> Think Outside the Box!
> *************************************************
> "Nedim" <Ne***@discussions.microsoft.com> wrote in message
> news:451468DB-7AAD-4DB9-A816-7AFB6121F359@microsoft.com...
> > first let me say sorry if this is in the wrong place, i'm pretty new to
> > programming and to be honest i am a bit intimidated by these forums.
> >
> > now that i've got that out of the way, i was bored and decided to make a
> > small text application in Visual Basic 2005,
> >
> > i have one list box, one label and ten buttons.
> >
> > the list box has 8 colors listed, and when one of them is selected and the
> > OK button clicked the text in the label changes color, the same with other
> > 8
> > buttons, but instead of selecting a color from the list the other buttons
> > change the color of the text directly.
> >
> > the problem is the tenth button, it's supposed to loop trough all 8
> > colors,
> > but it skips directly to the last one (purple) and stays there, the code i
> > used is this:
> >
> >
> >
> >        Dim myColor() As Color = {Color.Blue, Color.Red, Color.Green,
> > Color.Yellow, Color.Black, Color.White, Color.Orange, Color.Purple}
> >
> >        Dim textcollor As Color
> >        For Each textcollor In myColor
> >            Label1.ForeColor = (textcollor)
> >        Next
> >
> >
>
>
>
Author
13 Jun 2006 5:59 AM
Cor Ligthert [MVP]
Nedim,

To do it step by step.

If you make a same array for your labels as for your collors than you can
do.

for i as integer = 0 to myColor.lenght
    mylabelInArray(i).ForeColor = mycolor(i)
next

There are endless alternatives by the way

I hope this helps,

Cor

Assuming that your textboxes are in the same sequence and are
Show quoteHide quote
"Nedim" <Ne***@discussions.microsoft.com> schreef in bericht
news:1D09F8B2-7C2B-4C9A-AC27-ECE81FFE2B89@microsoft.com...
> yes, that is correct, i would like it to scroll trough all the colors i
> have
> set upon pressing the button.
>
> "Cowboy (Gregory A. Beamer)" wrote:
>
>> You want to see it scroll through the colors? If so, you need to pause
>> and
>> paint after each change. Otherwise, it is changing, but not painting
>> until
>> the entire loop is done. Am I understanding your desire correctly?
>>
>> --
>> Gregory A. Beamer
>>
>> *************************************************
>> Think Outside the Box!
>> *************************************************
>> "Nedim" <Ne***@discussions.microsoft.com> wrote in message
>> news:451468DB-7AAD-4DB9-A816-7AFB6121F359@microsoft.com...
>> > first let me say sorry if this is in the wrong place, i'm pretty new to
>> > programming and to be honest i am a bit intimidated by these forums.
>> >
>> > now that i've got that out of the way, i was bored and decided to make
>> > a
>> > small text application in Visual Basic 2005,
>> >
>> > i have one list box, one label and ten buttons.
>> >
>> > the list box has 8 colors listed, and when one of them is selected and
>> > the
>> > OK button clicked the text in the label changes color, the same with
>> > other
>> > 8
>> > buttons, but instead of selecting a color from the list the other
>> > buttons
>> > change the color of the text directly.
>> >
>> > the problem is the tenth button, it's supposed to loop trough all 8
>> > colors,
>> > but it skips directly to the last one (purple) and stays there, the
>> > code i
>> > used is this:
>> >
>> >
>> >
>> >        Dim myColor() As Color = {Color.Blue, Color.Red, Color.Green,
>> > Color.Yellow, Color.Black, Color.White, Color.Orange, Color.Purple}
>> >
>> >        Dim textcollor As Color
>> >        For Each textcollor In myColor
>> >            Label1.ForeColor = (textcollor)
>> >        Next
>> >
>> >
>>
>>
>>
Author
13 Jun 2006 7:19 AM
Göran Andersson
When you set the label color, a message is sent to the control to make
it change it's color. Use the DoEvents method to process the message
queue, then do nothing for a while.

Dim textColor As Color
For Each textColor In myColor
    Label1.ForeColor = textColor
    DoEvents
    Thread.Sleep(500)
Next


Nedim wrote:
Show quoteHide quote
> yes, that is correct, i would like it to scroll trough all the colors i have
> set upon pressing the button.
>
> "Cowboy (Gregory A. Beamer)" wrote:
>
>> You want to see it scroll through the colors? If so, you need to pause and
>> paint after each change. Otherwise, it is changing, but not painting until
>> the entire loop is done. Am I understanding your desire correctly?
>>
>> --
>> Gregory A. Beamer
>>
>> *************************************************
>> Think Outside the Box!
>> *************************************************
>> "Nedim" <Ne***@discussions.microsoft.com> wrote in message
>> news:451468DB-7AAD-4DB9-A816-7AFB6121F359@microsoft.com...
>>> first let me say sorry if this is in the wrong place, i'm pretty new to
>>> programming and to be honest i am a bit intimidated by these forums.
>>>
>>> now that i've got that out of the way, i was bored and decided to make a
>>> small text application in Visual Basic 2005,
>>>
>>> i have one list box, one label and ten buttons.
>>>
>>> the list box has 8 colors listed, and when one of them is selected and the
>>> OK button clicked the text in the label changes color, the same with other
>>> 8
>>> buttons, but instead of selecting a color from the list the other buttons
>>> change the color of the text directly.
>>>
>>> the problem is the tenth button, it's supposed to loop trough all 8
>>> colors,
>>> but it skips directly to the last one (purple) and stays there, the code i
>>> used is this:
>>>
>>>
>>>
>>>        Dim myColor() As Color = {Color.Blue, Color.Red, Color.Green,
>>> Color.Yellow, Color.Black, Color.White, Color.Orange, Color.Purple}
>>>
>>>        Dim textcollor As Color
>>>        For Each textcollor In myColor
>>>            Label1.ForeColor = (textcollor)
>>>        Next
>>>