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. -
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
Button1.BackColor = Color.Aqua
-
End Sub
can anyone help me
4 5470 pbmods 5,821
Recognized Expert Expert
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.
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.
SammyB 807
Recognized Expert Contributor
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. -
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
Button1.BackColor = Color.Aqua
-
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
hey terry, there is an easier way...
say you want 5 different colours to randomly be the back colour.. -
-
private sub button1_click(BlaBlaBla) handles BlaBlaBLa
-
-
dim aa as integer
-
-
aa = int (rnd () * 5) + 1
-
-
if aa = 1 then
-
button1.backcolor = blue (or what ever the code is for blue)
-
-
elseif aa = 2 then
-
button1.backcolor = green
-
-
elseif aa = 3 then
-
button1.backcolor = red
-
-
elseif aa = 4 then
-
button1.backcolor = yellow
-
-
elseif aa = 5 then
-
button1.backcolor = orange
-
-
endif
-
-
i hope this works, if it doesn't then PM me and i'll figure it out
ok then cya
sgrec7
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 spots on the
webpage. with a delay timer on them, so they keep changing as the page is
open. Not random each time the page is loaded.
If anyone can help it would be greatly appreaciated, I have tried many of
|
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
|
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).
Obviously, it can be done manually. But is there some template
mechanism which when applied to the forms, they automatically get
required formatting?
|
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 strings, which is a pain as we use our own database format with specific, user-defined data types and random access files. An example module content would be
Option Explici
Type Record
Operation As String * 4
unit As String * 2
Marker1 As String *...
|
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 sure how to correct it. The program runs fine
except for the warning. The warning puts a green squiggle line under
MyRecord
in the (Private Sub GetRecord()).
Warning Message:
Implicit conversion from 'System.ValueType' to...
| |
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 random colors, I feel that there
should also be some condition to ensure that they aren't too similar in
appearance, given that is likely to range from 2-20 say.
Any help much appreciated,
|
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()
function should be good enough to avoid that, so i may be seeing
things.
Zytan
|
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 then generate again and store new number in to database. I have created 10 label in the form which display the random number and at the same time I want random number generated to be stored in database. I don’t know how to start Plz help me with...
|
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 script I have developed, I am wondering if someone could fix my little bug with it.
This script runs perfectly fine, except once in a while, the color changing will "pause" because (according to Mozilla Firefox 3's error console) it is putting out...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |