PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] RichTextbox Problem-VBForums
Results 1 to 12 of 12

Thread: [RESOLVED] RichTextbox Problem

  1. #1

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,834

    Resolved [RESOLVED] RichTextbox Problem

    Hi all,
    I calling this code in a command button, to highlight a line in a richTextbox.
    VB Code:
    1. Private Declare Function SendMessageAsLong Lib "USER32" Alias "SendMessageA" _
    2.                         (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam _
    3.                         As Long, ByVal lParam As Long) As Long
    4. Private Const EM_GETLINECOUNT = &HBA
    5. Public Const EM_LINEINDEX = &HBB
    6. Private Const EM_SETSEL = &HB1
    7. Private Function HighLightText(Rich As RichTextBox, lLine As Long)
    8.     Dim chrsToStart As Long, chrsToEnd As Long, lineCount As Long
    9.     lineCount = SendMessage(Rich.hWnd, EM_GETLINECOUNT, 0, ByVal 0&)
    10.     If lLine > lineCount - 1 Then Exit Function
    11.      chrsToStart = SendMessage(Rich.hWnd, EM_LINEINDEX, lLine, ByVal 0&)
    12.      chrsToEnd = SendMessage(Rich.hWnd, EM_LINEINDEX, lLine + 1, ByVal 0&)
    13. '    Rich.SetFocus
    14.     If (chrsToEnd - chrsToStart) <> 2 Then
    15.         chrsToEnd = chrsToEnd
    16.     End If
    17.    
    18.     Call SendMessage(Rich.hWnd, EM_SETSEL, ByVal chrsToStart, ByVal chrsToEnd)
    19.    
    20. End Function
    21. Private Sub CmdFind_Click()
    22.   call HighLightText(RichTextBox1,40)
    23. End sub
    After selecting I used this code to replace the selected line
    with sometext .
    VB Code:
    1. rtffile1.SelText=Text.text
    It is running good in Win2000, and XP.But I am getting an Error message
    as attached,If I run this in this type of System
    Code:
    Windows XP with SP2
    P4,1 GB Ram,3.39 Ghz
    Can some body help to solve this problem

    Thanks in Advance
    Dana
    Last edited by danasegarane; Jun 27th, 2007 at 05:49 AM.
    Please mark you thread resolved using the Thread Tools as shown



    www.techreceipe.tk


  2. #2
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: RichTextbox Problem

    did you use Clipboard object anywhere?

  3. #3

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,834

    Re: RichTextbox Problem

    That is only Code I am using
    Please mark you thread resolved using the Thread Tools as shown



    www.techreceipe.tk


  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: RichTextbox Problem

    Quote Originally Posted by danasegarane
    It is running good in Win2000, and XP.But I am getting an Error message
    as attached,If I run this in this type of System
    Code:
    Windows XP with SP2
    P4,1 GB Ram,3.39 Ghz
    How is it running good in XP if in XP you are getting this error message?

    Could it be the service pack? Do you get this error message running XP SP1?

  5. #5

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,834

    Re: RichTextbox Problem

    Dear Hack,
    It is running in the OLD XP machine.I am getting this error in new machine only.The old machines also has the XP SP2.Could it be something because if the Hardware
    Please mark you thread resolved using the Thread Tools as shown



    www.techreceipe.tk


  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: RichTextbox Problem

    Quote Originally Posted by danasegarane
    Dear Hack,
    It is running in the OLD XP machine.I am getting this error in new machine only.The old machines also has the XP SP2.Could it be something because if the Hardware
    Well, one thing is for sure. It is not your code.

    If it were your code, then it would not work anywhere.

    If both have the same OS, with the same Service Pack, then you need to start looking at what else is different between the two.

  7. #7

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,834

    Re: RichTextbox Problem

    No Clues
    Please mark you thread resolved using the Thread Tools as shown



    www.techreceipe.tk


  8. #8

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,834

    Re: RichTextbox Problem

    I got this link .But I have no idea how to implement this in my codings
    Please mark you thread resolved using the Thread Tools as shown



    www.techreceipe.tk


  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,692

    Re: RichTextbox Problem

    Something like
    VB Code:
    1. Private Function HighLightText(Rich As RichTextBox, lLine As Long)
    2. Dim bRetry As Boolean
    3.  
    4.   On Error Goto ErrorTrap
    5.   '... your code
    6.   bRetry = True
    7.   While bRetry
    8.     'line in which error occurs
    9.   Wend
    10.   '... rest of your code
    11.   Call SendMessage(Rich.hWnd, EM_SETSEL, ByVal chrsToStart, ByVal chrsToEnd)
    12.   Exit Sub
    13.  
    14. ErrorTrap:
    15.   If MsgBox("The Clipboard is busy.", vbRetryCancel) = vbRetry Then
    16.     bRetry = True
    17.   Else
    18.     bRetry = False
    19.   End If
    20.  
    21. End Function
    should work.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: RichTextbox Problem

    Quote Originally Posted by danasegarane
    No Clues
    Do you have any hardware people in your shop that might be able to shed some light?

  11. #11

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,834

    Re: RichTextbox Problem

    Thanks to Hack to AL42.I used On Error Resume next and My Problem solved.And I also noticed that It is due to the HighSpeed RAM only.
    Please mark you thread resolved using the Thread Tools as shown



    www.techreceipe.tk


  12. #12
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: RichTextbox Problem

    Quote Originally Posted by danasegarane
    And I also noticed that It is due to the HighSpeed RAM only.
    That is causing the clipboard to be unavailable?

    Thats something to keep in mind.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width