Click here to Skip to main content
15,881,624 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI,
I am having Four text BOxes i writted code in vb 6.0 ,for spell check.the problem is the screen is flickering/or becoming weird.can any one help in this isuue.
Note:i used Word object and done the coding.can any one suggest to get out of this.

My code is
<pre lang="vb">

    Dim objWord As Object
    Dim objDoc  As Object
    Dim strResult As String

    'Create a new instance of word Application
    If (Len(txtbox.Text) = 0) Then

    Else

        Set objWord = CreateObject("word.Application")
        objWord.Visible = False
        Select Case objWord.version
            'Office 2000, xp, 2k3
                Case "9.0", "10.0", "11.0"
                Set objDoc = objWord.Documents.Add(, , 1, True)
            'Office 97
                Case Else
                Set objDoc = objWord.Documents.Add
        End Select

        objDoc.content = txtbox.Text
        objDoc.CheckSpelling
        objWord.Visible = False

        strResult = Left(objDoc.content, Len(objDoc.content) - 1)
        'correct the carriage returns
        strResult = Replace(strResult, Chr(13), Chr(13) & Chr(10))


        'Clean up
        objDoc.Close False
        Set objDoc = Nothing
        objWord.Application.Quit True
        Set objWord = Nothing

        ' Replace the selected text with the corrected text. It's important that
        ' this be done after the "Clean Up" because otherwise there are problems
        ' with the screen not repainting
        txtbox.Text = strResult


    End If

Done:
Exit Function

'in case user does not have word...
Err_Handler:
MsgBox Err.Description & Chr(13) & Chr(13) & "Please note you must have Microsoft Word installed to utilize the spell check feature.", vbCritical, "Error #: " & Err.Number
Resume Done

End Function



Thanks In Advance
Posted

1 solution

What hardware are you using XP(best or older), without hyper-threading I am guessing... :confused:

I believe the issue are having is a hardware issue, the OS is "pausing" as it is trying to run multiple apps at one time, I would guess you would get a similar result if you tried to open up an Excel panel inside of a word document (uses the same API's)... if this is the case then there is nothing you can do about it (on your machine)... :doh:

there is the possibility that it is a graphics/memory issue, but i would guess it is more of an OS limitation.. I would solve the problem by learning VB.Net.... :laugh:
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900