len(mystring)实时错误 6 溢出...求指正
Function linez(myString As String, dmystring As String) As Integer '找出字符串dmystring在mystring字符串的第几行
'循环变量
Dim e As Integer, hang As Integer
'获取文本框中的行数
Dim LineCount As Integer
'获取文本框中的字符总数
Dim Length As Integer
'要查找的字符串
Dim strFind As String
'因为不输入任何字符,文本框也有第一行,所以初始化行数为1
LineCount = 1
'获取文本框中字符的个数
Length = Len(myString) '''''''当字符串myString很长时,这个地方提示错误 6!!!!!!!!
'输入要查找的字符串
strFind = dmystring
For e = 1 To Length
'查找换行符Chr(10)为换行符,找到一个换行符总行数加1
If Mid(myString, e, 1) = Chr(10) Then
LineCount = LineCount + 1
End If
'查找指定的字符串是否在该行上,并且打印在窗体上
If Mid(myString, e, Len(strFind)) = strFind Then
'Debug.Print strFind; "在:"; LineCount; "行上"
linez = LineCount
End If
Next
End Function
郁闷...mystring的字符串,在txt的文本文件里有600多行....
mystring从网站用inet回来的....
[解决办法]
Length 不能超过32767
应该将其定义为long
[解决办法]
晕倒。。。。。
Function linez(myString As String, dmystring As String) As Integer '找出字符串dmystring在mystring字符串的第几行
'循环变量
Dim e As Integer, hang As Integer
'获取文本框中的行数
Dim LineCount As Integer
'获取文本框中的字符总数
。。。。。
你把Integer都改为Long, 尤其是Dim e as Long...
你下面的For e = 1 To Length,你看明白 了吗 ?