我的意思就是说在我那现成的代码里直接修改添加回车键所代表字符数的代码!
顶一下
[此贴子已经被作者于2006-5-17 13:13:56编辑过]
现在代码改为如下:
Private Sub Text1_Change()
Dim str As String
Dim T As Integer
Dim tx As Integer
Dim i As Integer
Dim n As Single
T = 0
For tx = 0 To Len(Text1.Text)
Text1.SelStart = tx
Text1.SelLength = 1
str = Text1.SelText
If str = "," Or str = "。" Or str = "!" Or str = "《" Or str = "》" Or str = "“" Or str = "”" Or str = ":" Or str = "(" Or str = ")" Or str = "(" Or str = ")" Or str = ";" Or str = "、" Or str = "?" Or str = "," Or str = "." Or str = "0" Or str = "1" Or str = "2" Or str = "3" Or str = "4" Or str = "5" Or str = "6" Or str = "7" Or str = "8" Or str = "9" Then T = T + 1
Next tx
T = T / 2
For i = 1 To Len(Replace(Text1.Text, " ", "")) - T
If Asc(Mid(Text1.Text, i, 1)) = 13 Then
n = n
Else
n = n + 1
End If
Next i
Text11.Text = n
Command2.SetFocus
End Sub
两种结果:
一、以粘贴文本文字形式显示在TEXT里的结果为,
(:“按照中共安徽省委办公厅、安徽省人民政府办公厅《关于开展县域经济考核评价,促进县域经济发展的实施意”共46。5个字符)
若是在一行里,就是46(实际为46。5),若分成两行就是47,分成三行就是48分成四行就是59,自动加1。。。。)于TEXT里,统计为为回车键字数算1,每按次回车键,就自动加1而不是加2了!
二、以在VB里打开\11.TXT形式并显示到TEXT里的结果为48(只有一行字的话一行,)
分成两行字的话就是49;分成三行字的话就是50;....以此类推.