computer 版 (精华区)
发信人: windoe (为中国电信做贡献), 信区: program
标 题: VB:如何计算一个字符串中的行数?
发信站: 听涛站 (Fri Mar 10 19:09:10 2000), 转信
Function CountStringLine(src_string As String) As Integer
On Error Resume Next
Dim string_flag As Integer
Dim line_cnt As Integer
Dim test_string As String
line_cnt = 0 '初始--> 行数为1
string_flag = 1 '标志为1
test_string = src_string
DoEvents
Do
line_cnt = line_cnt + 1
string_flag = InStr(test_string, vbCrLf) ’判断回车换行
test_string = Right(test_string, Len(test_string) - string_flag - 1)
Loop Until string_flag <= 0
CountStringLine = line_cnt
End Function
--By Kammi's SuperPost General Version
--
夜中不能寐,起坐弹鸣琴。
薄帷鉴明月,清风吹我襟。
孤鸿号外野,翔鸟鸣北林。
徘徊将何见,忧思独伤心。
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:0.909毫秒