我的程序需要实现如下功能:.
.
.
listlog.AddItem msg
listlog.ListIndex = listlog.ListCount - 1 'judge errrate
 If Mid(msg, 7, 1) = 0 Then               'errrate is serious
'display msg with red color

'这儿的代码如何写? Call savelog
 ElseIf Mid(msg, 7, 1) = 1 Then           'errrate is warning
'display msg with yellow color

'这儿的代码如何写? Call savelog
 End If

解决方案 »

  1.   

    ListBox本身不支持自定义颜色,你需要通过subclass来实现,参考:
    http://www.vbaccelerator.com/home/VB/Code/Controls/Combo_and_List_Boxes/Owner_Draw_Combo_and_List_Box/article.asp
      

  2.   

    可以考虑用LISTVIEW代替LISTBOX,代码简单。
      

  3.   

    可从
    http://www.vbaccelerator.com/home/VB/Code/Controls/Combo_and_List_Boxes/Owner_Draw_Combo_and_List_Box/VB6_Owner_Draw_Combo_List_Full_Source.asp
    下载例子简单点就用LISTVIEW吧
      

  4.   

    http://www.mvps.org/vbnet/index.html?code/subclass/combotabbedlist.htm