Results 1 to 8 of 8

Instr runtime error

Threaded View

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Instr runtime error

    I have this string which contains a hyphen "-". If i run the following code such that my temp_string has a "-" in it ........code will run fine. However, if i remove the "-" from the temp_string then the code has a run time error of "Invalid procedure call or argument".

    I know that the reason i get this run time error is that i am looking for a hyphen in a string that has no hyphen ...........not sure what to do. Need some way of making program not "stop" ......not sure.


    'temp_string = "Denosumab - Bone Loss Oncology"
    temp_string = "Denosumab"
    
    junk1 = InStr(1, temp_string, "-", 1) - 1
    
    junk2 = Left(temp_string, junk1)
    
    junk3 = Trim(junk2)
    
    MsgBox (junk1)
    MsgBox (junk2)
    MsgBox (junk3)
    Last edited by welchs101; 06-08-2011 at 02:35 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1