In the beginning of my code, (because it's kinda slow and I'm working to make it faster), there is an option to enable syntax highlighting. If the user clicks Yes, the wrapper will bind to the RichTextBox control, namely, the one and only one in the program. This works right.
Now, as part of adding to the functionality, my program generates a file for people to add various syntax commands for the wrapper to detect and highlight, and this also includes what color they'd like it highlighted. Now, on the load of the main form, if this feature is enabled the program loops through each line in the syntax db file and notes which syntax to highlight and what color it need be. This code looks like this:
RTBWrapperEnabledYN = True
RTBWrapper.bind(rtb:=RichTextBox1)
For Each Line In File.ReadAllLines(Dir1 + "SyntaxDB.txt")
Dim StrSplt(2) As String
StrSplt(0) = Line.Split.ToArray(0)
RTBWrapper.rtfSyntax.add(StrSplt(0), False, True, Color.Blue.ToArgb())
NextNote the RTBWrapper.rtfSyntax.Add() bit. Right now, for every syntax bit added, it is told to be "Blue" (hence the Color.Blue.ToArgb() arguement). What I would like to do, is take the color specified in a string with the syntax db file, and use that to replace Color.Blue.ToArgb() with whatever color the user wanted it to be. Like this: RTBWrapperEnabledYN = True
RTBWrapper.bind(rtb:=RichTextBox1)
For Each Line In File.ReadAllLines(Dir1 + "SyntaxDB.txt")
Dim StrSplt(2) As String
StrSplt(0) = Line.Split.ToArray(0) 'Syntax to be highlighted
StrSplt(1) = Line.Split.ToArray(1) 'Color to be used (i.e. Color.WhateverColor.ToArgb())
RTBWrapper.rtfSyntax.add(StrSplt(0), False, True, StrSplt(1))
NextHowever, this doesn't work because the arguement is interpreted as a string and not a ARGB Color choice for the .ToArgb bit to convert.My question is, how do I make it so I can convert a string to something that the program will understand and be able to use?
Many thanks again! :D
EDIT: Oops! Forgot to mention this is using Visual Basic.NET 2008 Express Edition SP1


Sign In
Create Account


Back to top









