Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2001
    Posts
    24

    Unanswered: Problem with VB Script statement

    Hello, I've got a problem with the following statement:

    help=mid( DTSSource("VARIABLES") , InStr( 1 , DTSSource("VARIABLES") ,"&PN=" , 1 )+3, Instr(InStr( 1 , DTSSource("VARIABLES") , "&PN=" , 1 ), DTSSource("VARIABLES"),"&",1) - (InStr( 1 , DTSSource("VARIABLES") , "&PN=" , 1 )+3))

    Do you know what's wrong?

    Thx!
    Last edited by Green4Ever; 11-07-02 at 09:15.

  2. #2
    Join Date
    Nov 2002
    Location
    Ohio
    Posts
    90
    Hello Green4Ever,

    Your statement is generating the same value for the second InStr that it did for the first InStr. You are ending up with help = Mid$(DTSSOURCE("VARIABLES"),N,-3). You need to change Instr(InStr( 1 , DTSSource("VARIABLES") , "&PN=" , 1 ), DTSSource("VARIABLES"),"&",1) to Instr(InStr( 1 , DTSSource("VARIABLES") , "&PN=" , 1 )+1, DTSSource("VARIABLES"),"&",1) to correct this.

    You could also try setting a variable = InStr(1,DTSSOURCE("VARIABLES"),"&PN=",1) outside the expression to make it easier to read and faster to execute as follows.

    lclSplit = InStr( 1 , DTSSource("VARIABLES") , "&PN=" , 1 )

    help = mid( DTSSource("VARIABLES") , lclSplit+3, Instr(lclSplit+1, DTSSource("VARIABLES"),"&",1) - lclSplit+3)

    Good Luck with your strings,
    Bruce Baasch

  3. #3
    Join Date
    Feb 2002
    Posts
    2,232
    For your future reference, when you have a problem like this in your code, you can split your complex statement into smaller simpler statements and merge together under the mid function. This would allow you to "step" through the smaller statements to see if there is a problem.

    And you may want to be more specific as to what the problem is.

Posting Permissions

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