Results 1 to 5 of 5

Thread: Problem with code - Resolved

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2002
    Posts
    34

    Problem with code - Resolved

    Hello,
    I'm getting an 'Invalid Procedure call or argument' error on this line. strTemp = Left$(InitialArray(x), InStr(InitialArray(x), "|") - 1)

    I can change the '-1' to a '+1' and it works fine but gives me an extra character that I don't want. What I'm trying to to is just get the string up to the delimiter, but not the delimiter. I can't figure out why I keep getting an error. Can somebody please help..
    Thanks, Rick
    Last edited by rruble88; Sep 27th, 2002 at 08:58 PM.

  2. #2
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    Look into the Mid Function

    Something Like :

    VB Code:
    1. strText = "Text to Trim !"
    2.  
    3. Mid(strText,1,Len(strText)-1)

    This would remove the ! character...
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    I'd also look at the source string.... make sure it doesn;t START with the delimiter
    VB Code:
    1. Dim strString As String
    2.  
    3. strString = "|Col1|Col2"
    4. MsgBox InStr(strString, "|") 'This will return 1
    5. MsgBox InStr(strString, "|") - 1 'This will return 0
    6. MsgBox Left$(strString, InStr(strString, "|") - 1)  'This will error, because you can't get the Left 0 characters.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Member
    Join Date
    Jul 2002
    Posts
    34
    Thanks for the replies, I've been looking a code too long today!
    I'm replacing a string in the array without adding the delimiter back into it..Thanks again

  5. #5
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    Add resolved to your first subject by editing your first post...

    Glad you figured it out...
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

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