472,791 Members | 1,428 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 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 17151
> 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: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.