Solved

Bold or colour for an individual word in a listbox for VBA/VB6

Posted on 2007-03-26
5
1,450 Views
Last Modified: 2012-06-27
Hi Experts,

I have a form with a listbox that uses the standard VBA listbox control.  

Private Sub UserForm_Initialize()
ListBox1.ListStyle = 1
ListBox1.MultiSelect = fmMultiSelectSingle
ListBox1.AddItem "I want to highlight the 6 numbers"
ListBox1.AddItem "Perhaps 1 could use bold for digits "
ListBox1.AddItem "I want 2 know if you could use a colour as well"
ListBox1.Selected(0) = True
ListBox1.ListIndex = -1
End Sub

This gives three lines of text in the listbox and a set of radio buttons to choose between them.

The text appears in regular, sans serif typeface.  Which is what I want.  However, I really want to put one word in bold / different colour in each line.  In this case, I want to highlight the digits, ie "6" in the first line, "1" in the second line or "2" in the third line.  

The only way to do that with the standard control seems to be placing "*" around either side of the word.  But that looks bad.  It really needs to be bold or italics or colour or something to really bring that individual word away from the rest of the sentence.

Is there any way to do this?  Is there any other kind of control for VBA / VB6 where I can keep my list and the radio buttons and also have the highlight of an individaul word in the sentence?

Thanks in advance,

PatternNut
0
Comment
Question by:PatternNut
  • 2
  • 2
5 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 18792074
Not too sure but first thought that you cannot bold a row in a Listbox control, perhaps you can try use a ListView control instead.
0
 

Author Comment

by:PatternNut
ID: 18792114
Hi Ryan,

Thanks for this... but I don't want to bold a row.  I want to bold an individual word within a row.  Do you think listview might be able to do that?

Cheers,

PatternNut
0
 
LVL 49

Assisted Solution

by:Ryan Chong
Ryan Chong earned 125 total points
ID: 18792358
Hi,

I got no aware of any control can customize only certain part of its content that present in a row format. The only thing I'm thinking is using HTML control, where you can customize perfectly to what you want, but I think this is not what you want..
0
 
LVL 22

Accepted Solution

by:
danaseaman earned 375 total points
ID: 18793318
You would need to  create and ownerdraw listbox that accepts basic Html for items and you will need a Html parser to do this.

To do this yourself would be take several days even for an experienced programmer.

OwnerDraw ListBox with source code:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=62442&lngWId=1

Here are 2 Html parsers with source code:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=30318&lngWId=1
http://www.vbthunder.com/software/cooltips/index.php

This is a commercial product that supports Html but it looks more like a WebBrowserControl:
http://hotlist-html-listbox-activex-control.eztools-software.qarchive.org/
0
 

Author Comment

by:PatternNut
ID: 18818288
Hi both,

Obviously this isn't the answer that I wanted to hear... but it is an answer and it is right.  And Danaseaman, the links you sent are really helpful.  I really appreciate the help that the two of you provided on this one and even if it's not what I wanted to hear, it's really good you took the time to write it.  Big, big help for me.

Thanks,

PatternNut
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now