473,406 Members | 2,217 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,406 software developers and data experts.

Visual basic random colors

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.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Button1.BackColor = Color.Aqua
  3.     End Sub
can anyone help me
Sep 1 '07 #1
4 5455
pbmods
5,821 Expert 4TB
Heya, Terry. Welcome to TSDN!

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.

I'm going to go ahead and move this thread to the Visual Basic forum, where our resident Experts will be better able to help you out.
Sep 1 '07 #2
Thank you, this was my first time to your web sight and got a little confused, so i thank you for your patience
Heya, Terry. Welcome to TSDN!

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.

I'm going to go ahead and move this thread to the Visual Basic forum, where our resident Experts will be better able to help you out.
Sep 1 '07 #3
SammyB
807 Expert 512MB
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.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. Button1.BackColor = Color.Aqua
  3. End Sub
can anyone help me
See this thread for an intro to random numbers. Just look at my posts that deal with .NET. You've found and used the Color class; now, you just need to create a new Color object and set the Red, Green, and Blue components to a random number. HTH --Sam
Sep 1 '07 #4
sgrec7
59
hey terry, there is an easier way...

say you want 5 different colours to randomly be the back colour..

Expand|Select|Wrap|Line Numbers
  1.  
  2. private sub button1_click(BlaBlaBla) handles BlaBlaBLa
  3.  
  4. dim aa as integer
  5.  
  6. aa = int (rnd () * 5) + 1
  7.  
  8. if aa = 1 then
  9. button1.backcolor = blue (or what ever the code is for blue)
  10.  
  11. elseif aa = 2 then
  12. button1.backcolor = green
  13.  
  14. elseif aa = 3 then
  15. button1.backcolor = red
  16.  
  17. elseif aa = 4 then
  18. button1.backcolor = yellow
  19.  
  20. elseif aa = 5 then
  21. button1.backcolor = orange
  22.  
  23. endif
  24.  
  25.  
i hope this works, if it doesn't then PM me and i'll figure it out

ok then cya

sgrec7
Sep 2 '07 #5

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

Similar topics

10
by: Virus | last post by:
Ok well what I am trying to do is have 1.) the background color to change randomly with 5 different colors.(change on page load) 2,) 10 different quotes randomly fadeing in and out in random...
1
by: Job Lot | last post by:
how to genrate random colors without repeat of the same color or color code. I am creating a line graph using ComponentOne Chart control and what to show series with different colors. thanx
3
by: ssb | last post by:
Hello, I have multiple forms in my access application. I want all the forms to have consistent formatting for fields appearing on the forms (i.e. same background color, fonts, font color etc). ...
4
by: LCAdeveloper | last post by:
I have had to move to Visual Studio.NET Pro. from Visual Basic 4.0 and am now starting to re-write our code. I was a bit surprised to find that Visual Basic.NET no longer supports fixed length...
6
by: Tom McL. | last post by:
I'm trying to move a program that was designed using Visual Studio 2003 and (Visual Basic) into Visual Studio 2005. When it runs I get the following warning in the Error List Window and I'm not...
12
by: Adam Hartshorne | last post by:
Hi All, I was wondering if somebody could post a few lines of code which would produce random colors, which will be used in defining different regions on a mesh. So in addition to having n...
41
by: Zytan | last post by:
Anyone do any tests on it? I would assume it has improved since C's rand(), but who knows. For some reason, and it could just be coincidence, I seem to see patterns. But even a crappy rand()...
5
by: JuAn2226 | last post by:
How do I create database which will store the random number that generated before I reset the random number and how do I check that new random number after I reset is exists in database. If exist...
11
by: moltendorf | last post by:
Hey everyone, as I have been by far pleased with some of the top helpers on this forum, I have decided to send another one your way. Even though I am personally having minimal issues with this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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
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...
0
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
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
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...

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.