473,406 Members | 2,620 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.

VB.NET backcolor syntax

Hi,

Can anyone tell me the correct syntax when using a variable to control
the color property?

This works ok:
If ABC2flash Then Label61.BackColor = Color.Yellow

This doesn't, showing syntax error in source code:
Dim ABC1col As String = "Color.Yellow"
If ABC2flash Then Label61.BackColor = ABC1col

Thanks
Jul 21 '05 #1
4 17190
> Can anyone tell me the correct syntax when using a variable to control
the color property?

This works ok:
If ABC2flash Then Label61.BackColor = Color.Yellow

This doesn't, showing syntax error in source code:
Dim ABC1col As String = "Color.Yellow"
If ABC2flash Then Label61.BackColor = ABC1col


I don't use VB.NET myself (see the note at the end of this posting), but
I think I can guess at your problem. The BackColor property is a number
(in VB6 it would be a Long, but I'm not sure of the data type in VB.NET,
you'll have to look that up in your help files). You have defined
ABC1col as a String variable and are trying to assign a String variable
to a property requiring a numerical data type... hence, your error. Try
this (substituting the correct data type where I used <NumericDataType>
as a place holder):

Dim ABC1col As <NumericDataType> = Color.Yellow
If ABC2flash Then Label61.BackColor = ABC1col

Now, for the note I told you about...

Almost everybody in this newsgroup is using VB6 or lower. While you may
get a stray answer to VB.NET (including VB2003 and VB2005 which has
dropped .NET from its name) questions here, you should ask them in
newsgroups devoted exclusively to .NET programming. Look for newsgroups
with either the word "dotnet" or "vsnet" in their name.

For the microsoft news server, try these newsgroups for Visual Basic
..NET related questions...

microsoft.public.dotnet.languages.vb
microsoft.public.dotnet.languages.vb.upgrade
microsoft.public.dotnet.languages.vb.controls
microsoft.public.dotnet.languages.vb.data

And these for more general .NET questions

microsoft.public.dotnet.general
microsoft.public.vsnet.general

Note: There are many other .NET newgroups (use the first three "fields"
from the last two as templates when searching for them), but the above
ones should get you started.

Rick
Jul 21 '05 #2

<Da**@dimos.biz> wrote in message
news:a_********************@giganews.com...
Hi,

Can anyone tell me the correct syntax when using a variable to control
the color property?

This works ok:
If ABC2flash Then Label61.BackColor = Color.Yellow

This doesn't, showing syntax error in source code:
Dim ABC1col As String = "Color.Yellow"
If ABC2flash Then Label61.BackColor = ABC1col

Thanks


Use the Color.FromName function. You'll have to remove the "Color." part of
the string but it's a start.

Example:
Label.BackColor = Color.FromName("Yellow")

Keith R. Weimer
Way Too Happy Software
Jul 21 '05 #3
Many thanks Keith,

FromName works just fine !

Dave
Jul 22 '05 #4
Thanks Rick,

Tried your suggestion - it didn't work either, but thanks for the kind
suggestion.

The FromName option in other reply seems to work, so I'm sorted out ok.

Thanks for the advice on the correct groups.

Best regards

Dave
Jul 22 '05 #5

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

Similar topics

3
by: pepino13 | last post by:
Hello, I have a a form called frmMissyFact, I have copied this form and called it frmMissyFactBackup which reads data from a backup database of the week before. I brought frmMissyFactBackup into...
2
by: perspolis | last post by:
HI I created a user control and place some control on it. I need when I change BackColor of user control,Back Color of other controls also change.. I used foloowing code: public override Color...
3
by: WilsonSmith | last post by:
I want to set the back color of radio button to some numeric value. How to do that(Syntax)? Something like this. rbtMyButton.BackColor = #63338b I am using .Net Framework 1.1. Thanks. W...
6
by: LU | last post by:
A)I build a datagrid based on a calendar date selection. B)When user clicks a button column on the datagrid I want to highlight this row. I use the code below to highlight the row. ***** CODE...
1
by: Firewalker | last post by:
I am attempting to change the backColor property on the previously instantiated buttons FROM a listbox_doubleClick event. I thought it would be something like this: If...
0
by: Jonesgj | last post by:
Hi, Using this control for the first time, and struggling with how to set the backcolor. What I am trying to do is read back data using the data reader and dependent on the value of a col in...
1
by: Nathan Sokalski | last post by:
I am using an ASP:Table Control to make a table. I know that the HTML TD tag has a background attribute and a bgcolor attribute. The TableCell has a BackColor property, which is the equivelant of...
4
by: ray well | last post by:
in my app i need to make a RichTextbox control transparent. i need it to be a like a pane of glass lying on a sheet of paper, where u can see everything on the sheet of paper not covered by text...
3
by: senfo | last post by:
I developed a Windows control in VS 2005 that inherits from the PictureBox Control that adds the ability to select images in a Windows application. It is, however, experiencing a strange issue...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
agi2029
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,...

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.