About Brandon Drake Expertise I can answer questions regarding the Graphics object, file access, general optimization, printing (on paper), user controls, program mathematics, the registry, creating macros, processes, and fundamental or basic questions. I have made a few asp.net pages but I do not know the language extensively. I have not done much work with databases but I have created my own database systems.
Experience I have been programming with visual basic for 6 years. In all I have written programs in about 8 programming languages, although, I only know about 3 well. I have written a few applications but mainly I like to write programs for fun.
Expert: Brandon Drake Date: 7/22/2006 Subject: Multiple visual changes to form in one sub
Question Ok that explains what I'm seeing. Thank you. If I could ask you one more question then on delays. Apparently I am misunderstanding the use of the timer. How can I add a pause between color changes?
-------------------------
Followup To
Question -
Hey Brandon,
I'm trying to change the background color of an image box repeatedly by just clicking one button.
The problem I'm running into is nothing will change until the sub ends and the only color that shows up is the last color that was assigned to the box background.
I've run the script line by line and it isn't my timer between color changes that is giving me problems. Simply nothing happens to the form until the sub ends.
Do I need to do something between color changes to force an update to the form or is it something else entirely that I'm missing?
Here is an example of what I'm trying to do:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.BackColor = Color.Chocolate
PictureBox2.BackColor = Color.Azure
PictureBox3.BackColor = Color.Gainsboro
First, when a Sub executes, it executes line by line, as fast as the processor can do it--The background color IS changing but it is so fast that you can't see it and the last color is the only color you see because it is the last change made to the picture box.
If you execute the Sub line by line using the debugger, you will not see the changes though. Visual changes do not normally show up when using the debugger.
What you need to do is detect which color the picture box currently is and then determine which color to make it--So if you determine the color is Chocolate, change the color to Azure and if you determine the color is Gold, change it to Tan.
Good Luck,
Brandon Drake
Answer Naimah,
There is no easy way to pause while IN a sub. The Timer control is used to run a piece of code every x seconds where x is a number you specify.
When you use Timer1.Start() you are telling the timer to "Turn on" and start executing a piece of code every x seconds.
The Timer Tick() event is the piece of code that executes. If you double click the timer control it should take you to it's Tick() event. The code that you put inside the tick event is the code that will execute every x seconds.