Results 1 to 5 of 5

Thread: whats wrong

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2001
    Location
    India,Karnataka,Bangalore
    Posts
    61

    whats wrong

    i tried a lot to get rid of the errors but i could'nt
    please help me ' the error its giving is 'type missmatch'

    Private Sub cmdFindNext_Click()
    On Error GoTo error_handler
    Dim position As long
    Dim str1 As String
    Dim str2 As String

    str1 = frmEDITOR.rtbEditor.Text ' main form's text box(richtext box)
    str2 = txtfind.Text 'just a text box

    If chkMcase = vbChecked Then
    position = InStr(str1, str2, vbBinaryCompare)
    Else
    position = InStr(str1, str2, vbTextCompare)

    End If

    Exit Sub

    error_handler:
    MsgBox Err.Description
    End Sub

  2. #2
    AIS_DK
    Guest
    First of all uncomment your On Error statement, and see which line causes the error.

  3. #3
    Code:
        Dim position As Long
        Dim str1 As String
        Dim str2 As String
        
        str1 = "blah testing this out"
        str2 = "testing"
        
        position = InStr(1, str1, str2, vbBinaryCompare)
        Debug.Print position
    InStr([start],[string1],[string2],[Compare as VbCompareMethod])

    You didn't give it a starting place in the InStr.
    Matt Bradbury

    An optimist will claim the glass is half full.
    A pessimist that it is half empty.
    I just think the glass is too big.

  4. #4
    Member
    Join Date
    Oct 2000
    Location
    Hooglede (belgium)
    Posts
    63
    Hi,
    if the type of compare is specified you have to say where he must start.
    So use:

    If chkMcase = vbChecked Then
    position = InStr(1, str1, str2, vbBinaryCompare)
    Else
    position = InStr(1, str1, str2, vbTextCompare)
    end if

    Greetings.
    VB, C/C++, ASP, HTML, Javascript, Java, SQL, VB.NET

  5. #5
    Member
    Join Date
    Oct 2000
    Location
    Hooglede (belgium)
    Posts
    63
    Seem's like we posted on the same time rebelDev.
    VB, C/C++, ASP, HTML, Javascript, Java, SQL, VB.NET

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