Results 1 to 3 of 3

Thread: Questions on ByRef

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Posts
    30

    Questions on ByRef

    I have a function in my program that uses the word spell checker to spell check a text field in my program. It calls one variable by reference which represents the current word in the word list being checked. There is a loop in the code that says if the word is spelled correctly, check next word. The problem i am having is that if the word currently being checked (wrdlst(Wrd)) is spelled correctly, The value of the variable Wrd will get correctly set to the index of the next incorrect word at the end of the function, but when it exits the function, the value of Wrd is not passed back to the refernce variable. It does not have this problem until it finds a correctly spelled work. thanks again.

    Code is as follows:

    Private Sub CheckNextWord(ByRef Wrd As Integer)
    If Wrd > x Then
    MsgBox "Spell Check Completed!"
    Exit Sub
    End If
    i = 0
    ChangeBtnState False
    With Form1.ProbDisc
    wrong = True
    '************ Heres the loop **********8

    While wrong And Wrd < x
    wrong = mobjWordApplication.CheckSpelling(WrdLst(Wrd).Text, , True, "C:\Program Files\Common Files\Microsoft Shared\Proof\MSSP3EN.LEX")
    If wrong Then Wrd = Wrd + 1
    Wend
    '************ That was the loop ********

    .SelStart = WrdLst(Wrd).BeginPos - 1
    .SelLength = WrdLst(Wrd).EndPos - WrdLst(Wrd).BeginPos + 1
    StatusBar1.SimpleText = WrdLst(Wrd).Text
    If Not wrong Then
    Set mobjSuggestions = Nothing
    Set mobjSuggestions = mobjWordApplication.GetSpellingSuggestions(WrdLst(Wrd).Text)
    For Each objSuggestion In mobjSuggestions
    List1.AddItem CStr(objSuggestion.Name), i
    i = i + 1
    Next
    End If
    If i > 0 Then List1.ListIndex = 0
    Text1.Text = List1.Text
    End With
    ChangeBtnState True
    End Sub

  2. #2

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Posts
    30

    Supplemental Info

    The test string i am using (problem occurs regardless of text string but...) is:

    hre si teh tst docmnt fer the spell cheker to erally giev it a good test.

    It works up until the word cheker. It builds the list for the word cheker when it finds that its misspelled, displays it, the upon exit the variable passed in the Wrd position is set back to 7, or the index of the word "the".

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Posts
    30

    Talking ARRRRRRRRGGGGG!! :)

    well, i figured out what the problem was. I was call the procedure with the statment CheckNextWord (y). I removed the () and it works fine now. its always something simple like that.. guess i dont know the syntax well enough yet...

Posting Permissions

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



Click Here to Expand Forum to Full Width