Tech Off Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

problem with VBSCRIPT!

Back to Forum: Tech Off
  • User profile image

    sub ClickBtn(key)

        dim bef,rch

        if(InStr("/*-+",rch) and InStr("/*-+",key)) then
            msgbox "Error!",vbOkOnly+vbInformation,"Warning!"
            call BtnClear()
            exit sub
        end if


    end   sub

    Is there anyone can tell me what's wrong with the code above?

    if rch equals -  +  /  *, the program should go to "IF STATEMENT".

    but fail to do that. why?

  • User profile image

    Spaces are your friends.

    The functions don't return boolean values, they return the index of the found substring. In VBS -1 is true, not >0, so you'll need to change your evaluation expression to this:

    If InStr( "/*-+" , rch ) > -1 And InStr( "/*-+",  key ) > -1 Then

  • User profile image

    OK! Thank you. W3bbo.

    I got it.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.