Hi guys,
Is it possible to use multiple colors in a multiline textbox.
It's because I have a userform with some buttons like for opening a txt/csv file.
And in the form I have a multiline textbox that I use as kind of LOG window.
So I use it like:
And I would like to paste the things that are correct in GREEN and things they go wrong in RED and maybe other things just in a default black.txtLog.Value = txtLog.Value & "File selected: " & csvFilename & vbCrLf
The only thing I find is forecolor but like in the example below the whole textbox changes color:
I suppose this doesn't work because forecolor changes the color for the whole textbox.txtLog.Value = txtLog.Value & "File selected: " & csvFilename & vbCrLf txtLog.ForeColor = RGB(0, 255, 0) txtLog.Value = txtLog.Value & "Some green text " & vbCrLf txtLog.ForeColor = RGB(0, 0, 255) txtLog.Value = txtLog.Value & "Some Blue text text " & vbCrLf
Is there a way to achieve what I'm trying to do?
Thanks in advance.
Cheers
No I'm afraid there isn't way to do this with a standard textbox control.
You could try a Rich TextBox control.
Hi,
Thanks for replying.
I googled your suggestion about Rich TextBox cause I didn't know it existed. So apparently I have to add it in the workset.
It's called Microsoft Rich Textbox Control, version 6.0 and it's pointed to c:\windows\system32\RichTx32.ocx (this is on my laptop with win7)
I'm afraid that this Rich TextBox won't work if the person who is going to use the form doesn't have this ocx file right?
There seem to be other problems with the Rich TextBox about security and that other ppl won't be able to execute the file.
I'm so surprised that there isn't an (easy) way to make something like this and that would work to whoever you distribute your file/form.
So if you or anyone else have a better suggestion to achieve using colors, please let me know.
Cheers.
What exactly is in the multiline textbox?
You mention some sort of 'log'.
Hi,
Well I want to show information about what is happening.
Like:
Importing File OK
Data to Array OK
Array to Class OK
or
Select correct file. No file imported.
Importing File OK
And so on. These are just examples by the way.
So this box is used to show what is happening and if they forgot something or did something wrong.
It is not for letting the user type something into to the box.
Thanks
Why not use a listbox for that?
Or if you do want to format the text a ListView, which is another non-standard control but is more likely to be present than the Rich Textbox control.
Hi,
That's good advice. I don't mind if it's a listbox.
I didn't think about that.
I'll have to see what the difference is between a listbox and listview.
Thanks again for keep helping through this!!!
I really appreciate it.
I suppose the important difference for what you want to do is that you can format the items in a ListView, which is something you can't do in a ListBox.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks