首先要定位到行(比较麻烦好象),然后求这行的 len 。

解决方案 »

  1.   

    都用,综合运用啦!先判断所在行数再
         字数=len(text1.text/richtextbox.text)
      

  2.   

    告诉你一个最有效的方法
    把光标放在行首,然后用left(text1.text,text1.selstart,1)取字符,一个一个取,然后在判断是否有chr(13)+chr(10),如果换行,就结束。
    这个方法怎么样,只是对自动换行的textbox和richtextbox无效。
      

  3.   

    还是用GetLineFromChar这个属性比较好k=12'指定要计算字符的行
    hang=0
    for i=1 to len(richtextbox1.text)
     p= RichTextBox1.GetLineFromChar(i)
     if p=k then hang=hang+1
    next i这样hang最后的值就是那一行字符数。如果为了精确,最好判断一下这一行中有没有chr(13)以及chr(10)这两个字符,如果有则把这两个字符数减去
    循环中的代码可以改成这样:
     p= RichTextBox1.GetLineFromChar(x)
     pp=asc(mid(richtextbox1.text,i,1))
     if p=k and pp<>10 and pp<> 13 then hang=hang+1
    这样就行了。
      

  4.   

    EM_GETLINECOUNT
    An application sends an EM_GETLINECOUNT message to retrieve the number of lines in a multiline edit control. EM_GETLINECOUNT 
    wParam = 0; // not used; must be zero 
    lParam = 0; // not used; must be zero 
     
    Parameters
    This message has no parameters. Return Values
    The return value is an integer specifying the number of lines in the multiline edit control. If no text is in the edit control, the return value is 1. QuickInfo
      Windows NT: Requires version 3.1 or later.
      Windows: Requires Windows 95 or later.
      Windows CE: Requires version 1.0 or later.
      Header: Declared in winuser.h.