Announcement

Collapse
No announcement yet.

Split a string function in VBScript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Split a string function in VBScript

    I'm trying to split a string into an array variable (or separate variables), from what I can see in VBScript documentation it should be this:

    Dim String
    Dim Array (4)

    Array=Split("this,is,a,test,split",",")

    or

    Array=Split("this,is,a,test,split",",",-1,1)

    When I run the script in HS3 I get the error:

    Type mismatch in line 348 More info: Type mismatch (the line is the line that command is)

    Can anybody help with what I'm doing wrong?

    Thanks

  • #2
    Check out the example at the bottom for a vb.net example
    http://msdn.microsoft.com/en-us/libr...(v=vs.90).aspx

    For a vb script example see this example:
    http://www.w3schools.com/vbscript/func_split.asp
    -Rupp
    sigpic

    Comment


    • #3
      Hi Rupp,

      from what I can see (and I'm fully prepared to admit that I'm missing something obvious here) the script should work as I posted it. I'm writing this in VB Script.

      The problem seems to be the split command, that is where HS is putting up the error, but all my reading of VBScript docs seems to say the command is correct.

      Comment


      • #4
        Try not DIMming the array.

        I like VB.net better than vbscript, it seems better behaved.

        Z

        Comment


        • #5
          Make sure the extension of your script file is not ".vb"

          tenholde
          tenholde

          Comment


          • #6
            Originally posted by vasrc View Post
            Try not DIMming the array.

            I like VB.net better than vbscript, it seems better behaved.

            Z
            Thanks for your help, for some reason I need to DIM the array as a normal variable, then everything works. so instead of DIM ARRAY(x) it has to be just DIM ARRAY

            seems strange but whatever works

            Thanks for your help!

            Comment


            • #7
              Like I said, try VB.net.. I think it's more structured (ie consistent)

              Is Vbscript supported on Mono (ie Linux)??

              Z

              Comment

              Working...
              X