Solved

How to find a color

Posted on 2011-02-10
6
199 Views
Last Modified: 2012-05-11
I have a Visual Basic 2008 Windows form. I have a text string that contains "SteelBlue". How do I set the forecolor of a text control to Color.SteelBlue?
Thanks,
pat
0
Comment
Question by:mpdillon
6 Comments
 
LVL 8

Expert Comment

by:pdd1lan
ID: 34863986
Me.TextBox1.ForeColor = Color.SteelBlue
0
 

Author Comment

by:mpdillon
ID: 34864039
pdd1Ian,
I do not think that is what I asked. I agree that Color.SteelBlue can be used to set the forecolor. But I don't have a COLOR variable. I have a text string, "SteelBlue". Don't I have to use a For Each statement to find a match between the COLOR.Name and the Text string, "SteelBlue"?
pat
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 34864072
Try

Color.FromName("SteelBlue")
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 51

Expert Comment

by:HainKurt
ID: 34864098
try:

dim myColorName as String = "SteelBlue"
Me.TextBox1.ForeColor = Color.FromName(myColorName)
0
 

Author Closing Comment

by:mpdillon
ID: 34864129
CodeCruiser, Thank you. That worked for me.
Dim clr As Color = Nothing
clr = Color.FromName("SteelBlue")
me.Textbox1.forecolor = clr
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34869717
Glad to help :-)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question