在RTF TEXT中使用色彩

*** Add VB code in a RTF control Call InitColorize Call
ColorizeWords(rtfVBCode)
*** Now your VB code in your RTF control is colorized  
Source Code:  
#VBIDEUtils#************************************************************
*Programmer Name : Waty Thierry
* Web Site : www.geocities.com/ResearchTriangle/6311/
* E-Mail : waty.thierry@usa.net
* Date : 30/10/98
* Time : 14:47
* Module Name : Colorize_Module
* Module Filename : Colorize.bas
**********************************************************************
*Comments : Colorize in black, blue, green the VB keywords
*
*
**********************************************************************
Option Explicit
Private gsBlackKeywords As String
Private gsBlueKeyWords As String
Public Sub ColorizeWords(rtf As RichTextBox)
#VBIDEUtils#************************************************************
* Programmer Name : Waty Thierry
* Web Site : www.geocities.com/ResearchTriangle/6311/
* E-Mail : waty.thierry@usa.net
* Date : 30/10/98
* Time : 14:47
* Module Name : Colorize_Module
* Module Filename : Colorize.bas
* Procedure Name : ColorizeWords
* Parameters :
* rtf As RichTextBox
**********************************************************************
* Comments : Colorize in black, blue, green the VB keywords
*
*
**********************************************************************
Dim sBuffer As String
Dim nI As Long
Dim nJ As Long
Dim sTmpWord As String
Dim nStartPos As Long
Dim nSelLen As Long
Dim nWordPos As Long Dim cHourglass As class_Hourglass
Set cHourglass = New class_Hourglas br> sBuffer = rtf.Text sTmpWord = "" With rtf
For nI = 1 To Len(sBuffer)
Select Case Mid(sBuffer, nI, 1)
Case "A" To "Z", "a" To "z", "_"
If sTmpWord = "" Then nStartPos = nI
sTmpWord = sTmpWord & Mid(sBuffer, nI, 1)
Case Chr(34)
nSelLen = 1
For nJ = 1 To 9999999
If Mid(sBuffer, nI + 1, 1) = Chr(34) Then nI = nI + 2
Exit For
Else
nSelLen = nSelLen + 1
nI = nI + 1
End If
Next
Case Chr(39) .
SelStart = nI - 1
nSelLen = 0
For nJ = 1 To 9999999
If Mid(sBuffer, nI, 2) = vbCrLf Then
Exit For
Else
nSelLen = nSelLen + 1
nI = nI + 1
End If
Next
.SelLength = nSelLen
.SelColor = RGB(0, 127, 0)
Case Else
If Not (Len(sTmpWord) = 0) Then
.SelStart = nStartPos - 1
.SelLength = Len(sTmpWord)
nWordPos = InStr(1, gsBlackKeywords, "*" & sTmpWord & "*", 1)
If nWordPos <> 0 Then
.SelColor = RGB(0, 0, 0)
.SelText = Mid(gsBlackKeywords, nWordPos + 1, Len(sTmpWord))
End If
nWordPos = InStr(1, gsBlueKeyWords, "*" & sTmpWord & "*", 1)
If nWordPos <> 0 Then
.SelColor = RGB(0, 0, 127)
.SelText = Mid(gsBlueKeyWords, nWordPos + 1, Len(sTmpWord))
End If
If UCase(sTmpWord) = "REM" Then
.SelStart = nI - 4
.SelLength = 3
For nJ = 1 To 9999999
If Mid(sBuffer, nI, 2) = vbCrLf Then
Exit For
Else
.SelLength = .SelLength + 1
nI = nI + 1
End If
Next
.SelColor = RGB(0, 127, 0)
.SelText = LCase(.SelText)
End If End If
sTmpWord = ""
End Select
Next
.SelStart = 0
End With
end sub
Public Sub InitColorize()
#VBIDEUtils#************************************************************
* Programmer Name : Waty Thierry
* Web Site : www.geocities.com/ResearchTriangle/6311/
* E-Mail : waty.thierry@usa.net
* Date : 30/10/98
* Time : 14:47
* Module Name : Colorize_Module
* Module Filename : Colorize.bas
* Procedure Name : InitColorize
* Parameters :
**********************************************************************
* Comments : Initialize the VB keywords
*
*
**********************************************************************
gsBlackKeywords ="*Abs*Add*AddItem*AppActivate*Array*Asc*Atn*"
gsBlackKeywords =gsBlackKeywords+"Beep*Begin*BeginProperty*"
gsBlackKeywords =gsBlackKeywords+"ChDir*ChDrive*Choose*"
gsBlackKeywords =gsBlackKeywords+"Chr*Clear*Collection*Command*Cos*CreateObject*"
gsBlackKeywords =gsBlackKeywords+"CurDir*DateAdd*DateDiff*DatePart*DateSerial*DateValue*"
gsBlackKeywords =gsBlackKeywords+"Day*DDB*DeleteSetting*Dir*DoEvents"
gsBlackKeywords =gsBlackKeywords+"*EndProperty*Environ*EOF*Err*"
gsBlackKeywords =gsBlackKeywords+"Exp*FileAttr*FileCopy*FileDateTime*FileLen*Fix*Format*FV
gsBlackKeywords =gsBlackKeywords+"*GetAllSettings*"GetAttr*GetObject*GetSetting*Hex*Hide*Hour*"
gsBlackKeywords =gsBlackKeywords+"InputBox*InStr*Int*Int*IPmt*IRR*IsArray"
gsBlackKeywords =gsBlackKeywords+"*IsDate*IsEmpty*IsError*"
gsBlackKeywords =gsBlackKeywords+"IsMissing*IsNull*IsNumeric*IsObject*Item*Kill"
gsBlackKeywords =gsBlackKeywords+"*LCase*Left*Len*Load*"
gsBlackKeywords =gsBlackKeywords+"Loc*LOF*Log*LTrim*Me*Mid*Minute*"
gsBlackKeywords =gsBlackKeywords+"MIRR*MkDir*Month*Now*NPer*NPV*Oct*"
gsBlackKeywords =gsBlackKeywords+"Pmt*PPmt*PV*QBColor*Raise*Randomize"
gsBlackKeywords =gsBlackKeywords+"*Rate*Remove*RemoveItem*Reset*RGB*"
gsBlackKeywords =gsBlackKeywords+"Right*RmDir*Rnd*RTrim*SaveSetting"
gsBlackKeywords =gsBlackKeywords+"*Second*SendKeys*SetAttr*Sgn*Shell*"
gsBlackKeywords =gsBlackKeywords+"Sin*Sin*SLN*Space*Sqr*Str*StrComp"
gsBlackKeywords =gsBlackKeywords+"*StrConv*Switch*SYD*Tan*Text*Time*Time*"
gsBlackKeywords =gsBlackKeywords+"Timer*TimeSerial*TimeValue*Trim*TypeName"
gsBlackKeywords =gsBlackKeywords+" *UCase*Unload*Val*VarType*WeekDay*"
gsBlackKeywords =gsBlackKeywords+"Width*Year*"
gsBlueKeyWords = "*#Const*#Else*#ElseIf*#End"
gsBlueKeyWords = gsBlueKeyWords+"If*#If*Alias*Alias*And*As*Base"
gsBlueKeyWords = gsBlueKeyWords+"*Binary*Boolean*Byte*B"
End Sub

时间: 2024-08-03 18:40:26

在RTF TEXT中使用色彩的相关文章

设计中的色彩感情(下)

色调变化及类型 变调即色调的转换,是艺术设计中色彩选择多方案考虑及同品种多花色系列设计的重要课题,变调的形式一般有定形变调.定色变调.定形定色变调等. 1.定形变调 实质为保持形态(图案.花形.款式等)不变的前提下,只变化色彩而达到改变色调倾向的目的,是纺织.服装.装潢.包装.装帧.环艺等多种实用美术中,经常采用的产品同品种.同花形.多色调的设计构思方法. 定形变调主要有两种形式. (1)同明度.同纯度.异色相变调 即根据原有设计色调,保持明度.纯度不弯,只变化色相(原有色相对比距离不变)而改变

网站设计中的色彩如何搭配

  一个网页设计师对于颜色来说是比较敏感的,因为色彩搭配是整个网站的重要点.如果搭配的不合理就会产生层次不清晰,网站没有重点,如果搭配的过于艳丽,又有些太炫的感觉.每一个客户的审美都是不同的,所以设计师经常被顾客说这里改一下那里改一下,一直不懂得客户到底要个什么样的,因为视觉感官是很难用语言表达出来的. 网页设计中首先要注意的是色彩三要素,色彩可用色调(色相).饱和度(纯度)和明度来描述.人眼看到的任一彩色光都是这三个特性的综合效果.其次是色彩的强度,简单的说是不同色彩搭配对肉眼产生的影响的大小

游戏设计中的色彩哲学:没想象的那么简单

色彩的学问横跨物理.生物.心理.艺术和设计等若干学科--艺术家用它来点燃情感的共鸣,广告人用它来塑造产品的格调,而对游戏设计者而言,色彩不仅关乎"看",还关乎"用".本文将着重探讨游戏中的色彩及其应用,包括提升色彩视觉效果的相关技术和生物学效应等等. 游戏中的色彩:到底有什么用? 色彩的首要功能是帮助我们辨认不同的物体,在游戏中也是如此--现实的苹果是红色的,所以游戏中的苹果也是红色的,辨认起来就更加容易.除此之外,游戏中的色彩还跟艺术.设计和电影一样,有其他作用.

前端常见bug系列3:&lt;input type=&quot;text&quot;&gt;中emoji表情与文字并存时表情被截掉一部分

比如,有这个一个demo页面: <head> <meta charset="UTF-8"> <meta name="format-detection" content="telephone=no, address=no, email=no, time=no"> <meta name="viewport" content="width=device-width,user-sca

ios-在iOS中,想要判断text中输入范围

问题描述 在iOS中,想要判断text中输入范围 需要判断text中是否在0到100范围内,是的话进行跳转,否则弹出提示框,该如何做? 解决方案 http://blog.csdn.net/hintcnuie/article/details/17331971 限制数字范围在此基础上稍微修改,转换为数字,然后判断大小即可. 解决方案二: 参考http://blog.csdn.net/hintcnuie/article/details/17331971

mediaplayer-VB中Windows Media Player如何读取text1.text中的数据

问题描述 VB中Windows Media Player如何读取text1.text中的数据 Text1.text中的数据是多行的音乐地址,我想要点击一下按钮,然后让Windows Media Player插件开始读取Text1.text的第一行音乐地址,播放完毕后,再读取第二行的地址播放.这个该如何做到呢? 解决方案 定义一个Integer成员变量,写在方法外面,代表当前是第几行 Private currLineNum As Integer = 0 给WindowsMediaPlayer添加P

浅谈网页设计中的色彩理论

无可争议的是,色彩是任何设计领域中最重要的一方面. 设计师在决定了一个网站风格的同时,也决定了网站的情感,而情感的表达很大程度上取决于颜色的选择.颜色是很有力的工具,所有设计师在设计网页时就应该明白这一点. 一.颜色术语 你们当中很多人可能已经在学校学过一些色彩基础知识,让我们快速回顾一些术语,来更好的把握色彩和运用色彩. 色轮的主要组成 所有的色彩能在一个色轮中呈现.在这个色轮中,我们能把颜色分成3大块:原色,辅助色和第三颜色. 三原色分别是红色,蓝色和黄色.这些色彩是基础色,他们组成了色轮上

java-JAVA程序如何获取RTF域中的引入图片

问题描述 JAVA程序如何获取RTF域中的引入图片 我通过JAVA程序能打开NOTES邮件,并能取到正文域中的文字信息和附件,但现在碰到个问题,就是引入或是粘贴进来的图片(或WORD)不能获取.我试过了用EmbeddedObject对象,好像得不到这些信息. 请教各位,有没有什么方法能通过JAVA获取RTF域中的引入(粘贴)对象. 解决方案 跪求各位大神帮忙,---- 解决方案二: 自己顶一下,,那位给帮忙解决一下,能行在补加分

vb.net 新手,请问text中的数据如何引用

问题描述 vb.net 新手,请问text中的数据如何引用 1.请问text中的数据如何引用? 2.函数里面的值如何调用? 3.函数中的值如何返回?多次返回如何编程? 4,为什么有的时候if..then中的return不能够返回,然后提示函数没有函数值?难道要放在end if外面?如果是,多函数返回值如何处理? 楼主只有一星期将原先c++的程序用vb.net可视化了...但是...不懂...肿么办 解决方案 (1)Dim s As String = TextBox1.Text 或者Dim i A