教程中国
PHOTOSHOP CS9.0中文版 MAYA 8.5 FOR WINDOWS Corel Painter v9.0 Flash MX2004 中文版 Illustrator cs2 中文版
VC++6.0含sp6 中英文版 VB6.0 +sp6 简体中文版 Borland Delphi 7汉化版 MSDN for vb6.0中文版 Visual Studio 2005简体
教程中国下属 文件存储共享专家BIBIDU.COM 提供大型软件,教材,源码,电影,音乐,图书等下载 更多精品请点此进入
  您目前所在位置: 教程中国 >> 编程基地 >> VB >> Word Power! RSS订阅
Word Power!
教程(视频,书籍)下载:  ASP.NET AutoCAD 数据库 C# ASP java photoshop 网页设计 delphi 3dmax Flash C++ VB 张孝祥 实例   更多请进入BIBIDU搜索
IT搜索引擎   
Word Power!

Need to count the number of words in that jungle of text? Does your count conflict with the MS Word interpretation?

Stop scratching your head - let this copy-and-paste code snippet do all the hard work for you, using the same techniques as Microsoft itself.

Simply pass the GetWordCount function your text and it抣l return the number of letters used. It works by making the assumptions Microsoft Word does - such as that a hyphen at the end of a line signals one hyphenated word, not two separate words to be counted.

Usage

MsgBox GetWordCount(Text1.Text)Code

Public Function GetWordCount(ByVal Text As String) As Long

    注释:Assume a hyphen at the end of a line
    注释:is part of a full-word, so combine together
    Text = Trim(Replace(Text, "-" & vbNewLine, ""))
    
    注释:Replace new lines with a single space
    Text = Trim(Replace(Text, vbNewLine, " "))
    
    注释:Collapse multiple spaces into one single space
    Do While Text Like "*  *"
        Text = Replace(Text, "  ", " ")
    Loop

    注释:Split the string and return counted words
    GetWordCount = 1 + UBound(Split(Text, " "))
    
End FunctionTip by Karl Moore

来源:upschool.cn
作者:
关键字:Word,Power
发表日期:2006-12-20 20:00:59

网页显示有限 阅读全文请下载本文完整版WORD文档

上一篇:VB的热键技巧的终结篇   下一篇:在windows98下自动启动程序的10种方法


2009-1-10 10:38:44
本文的相类似文章
  • 遭遇Word文档病毒的解决办法
  • 木马伪装成word感染移动设备
  • Oracle中password file的作用及说明
  • Powerdesigner使用建议(完整版)
  • Linux Shadow-Password-HOWTO - 9. 常问问题及答案
  • Linux Shadow-Password-HOWTO - 8. 加入 shadow 支援 C 语言(2)
  • Linux Shadow-Password-HOWTO - 8. 加入 shadow 支援 C 语言(1)
  • Linux Shadow-Password-HOWTO - 7. 将 Shadow Suite 放进来使用(2)
  • Linux Shadow-Password-HOWTO - 7. 将 Shadow Suite 放进来使用(1)
  • Linux Shadow-Password-HOWTO - 6. upgrade或patch程式
  • 在学习中进步 在进步中成长 教程中国相随您的成长之路
    华腾联合科技股份有限公司版权所有
    广告联系:Rosibo@163.com