【发布时间】:2017-02-01 01:01:44
【问题描述】:
所以我有这个实际上是游戏聊天的文本框。当有人键入消息时,它会显示如下:用户名:消息
我想在这里做的是以某种方式使 UserName 文本始终以不同的颜色显示,因此它与实际消息有点分开。
这是我目前使用的代码:
AddChatMsg 0, userName & ": " & theMsg 'send it to the chatbox
Dim curColor As Long 'current text color
Dim userNameLength As Integer 'username length
userNameLength = Len(UserName) 'store username in integer var
With MyForm.ChatText
curColor = .SelColor 'set curColor
.SelLength = userNameLength 'set Length
.SelColor = vbRed 'change color
.SelText = UserName 'not sure wha this do
.SelColor = curColor 'update current color var
End With
这实际上效果很好,但是用户名仅在第一行是红色的:
如何使它适用于每一行?此外,如果可能的话,将字体更改为粗体将会很棒。谢谢!
【问题讨论】:
标签: vb6 richtextbox textcolor text-formatting