473,327 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Loopin trough colors

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
Jun 13 '06 #1
4 1084
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:45**********************************@microsof t.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

Jun 13 '06 #2
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:45**********************************@microsof t.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


Jun 13 '06 #3
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
"Nedim" <Ne***@discussions.microsoft.com> schreef in bericht
news:1D**********************************@microsof t.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:45**********************************@microsof t.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
>
>


Jun 13 '06 #4
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:
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:45**********************************@microsof t.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

Jun 13 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: aznFETISH | last post by:
I have a list of links that I ue on my page, I alternate background colors for these links in a table, I usually do it using a DB but this list of link is manually added into the page so my...
7
by: Laszlo Zsolt Nagy | last post by:
Hello, How can I determine the number of colors used in an image? I tried to search on Google but I could figure out. I read the PIL handbook but I do not see how to do it. Can anyone help? ...
0
by: Jurrie | last post by:
hi all, In my XML document i have <paragraph type="...">some text</paragraph> the type="..." specifies what type the paragraph is. This is all defined somewehere else in the document. The type...
1
by: Andrés Giraldo | last post by:
Hi! I'm trying to pass trough all the objects of a form but I have some text inputs in a DIV and I have many DIVs like this on my form. I'm doing something like: for (i = 0; i <...
0
by: Javier de la Torre | last post by:
Hi all, I'm wondering if someone has experiment problems using SQL statements with UNIONS trough the ODBC driver. For example this SQL statement: (SELECT DISTINCT compactes.numplec AS UnitId...
6
by: Danny Lesandrini | last post by:
I'm using an Access database to drive a web site and the colors of various table backgrounds are stored in Access. I want users of the Access database to be able to select colors for the site, but...
11
by: Paul Smith | last post by:
I have a button on my web page the backcolor of which I want to change: btnSample.backcolor = ???????? I want the color to be Gainsboro However I enter Gainsboro or color.Gainsboro I have...
1
by: Demi | last post by:
I want to be able to define standard colors in a base form, then have child forms use those values instead of standard colors. Ex in my base form I want to do this: Color myColor =...
4
by: Boni | last post by:
I want consuming a webserivce trough a proxy. I use this code. myService s = new myService (); System.Net.WebProxy proxyObject = new System.Net.WebProxy("http://proxyhost:8080"); s.Proxy =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.