Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 14th, 2007, 04:43 PM
Registered User
 
Join Date: Mar 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Changing the BackColor property of a Form

Hi,

I'm new to VB programming but used to program in Basic many years ago. My first attempt in VB 2005 is to create a form with Radio buttons on it which change the color of the Form when pressed. One of the Buttons is supposed to respond with a random color (well, one of 21 predefined ones!). I can't work out how to change the BackColor property with a single statement. All I can manage to do is have a Select Case structure with the 21 options predefined and choose which one to execute based on a random number like this --

 Select Case objRandom.Next(0, 20)
            Case 0
                frmMainForm.BackColor = Color.Aquamarine
                strColourName = " Aquamarine"
            Case 1
                frmMainForm.BackColor = Color.Beige
                strColourName = " Beige"

     and so on down to .............

            Case 20
                frmMainForm.BackColor = Color.Transparent
                strColourName = " Transparent"
        End Select

Is there a way of replacing the "Color.whatever" with a strVariable? Then I could replace the whole thing with one or two statements.

Thanks for any help.





Similar Threads
Thread Thread Starter Forum Replies Last Post
changing the backcolor property of the textbox Fehrer Access VBA 9 April 19th, 2016 10:59 AM
change TextBox.BackColor property onFocus event drasko ASP.NET 1.0 and 1.1 Basics 8 January 26th, 2009 12:23 AM
changing property doesn't work Vanni VB.NET 4 July 1st, 2005 07:50 AM
Problem when changing the Location property armandoa Crystal Reports 0 October 8th, 2004 06:21 PM
changing the onclick property dynamically? nerssi Javascript 8 September 21st, 2004 12:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.