compare strings

Author Message
webnot

  • Total Posts : 1
  • Scores: 0
  • Reward points : 0
  • Joined: 12/19/2008
  • Status: offline
compare strings Friday, December 19, 2008 6:31 PM (permalink)
0
Hi All
i am new to VB Script .... I need your help
Can any body tell me how i can i compare strings in VB Script right know i am doing it using Javascript and it is working fine but i have to do it in asp/VBscript the code for ref if here....



<script type="text/javascript">
var test1="hello,there,come,never,love,this,and,that,it,is,not,good";

var test1_array=test1.split(",");


var test2="good,never,come,there,love,is,that,it,and,hello";

var test2_array = test2.split(",");

var test1_Value;

var i=0, j = 0;

var found;

test1_Value ="";


for (i=0; i<=test1_array.length; i++)

{

found =0

for(j=0; j<=test2_array.length; j++)

{

if(test1_array == test2_array[j])

{

found =1

}


}

if (found ==0 )

{

if (test1_Value == "")

{

test1_Value = test1_array

}

else

{

test1_Value = test1_Value + "," + test1_array

}


}

}

alert( test1_Value)

</script>
 
#1
    TNO

    • Total Posts : 2094
    • Scores: 36
    • Reward points : 0
    • Joined: 12/18/2004
    • Location: Earth
    • Status: offline
    RE: compare strings Monday, December 29, 2008 1:58 AM (permalink)
    0
    To compare in JavaScript, all you have to do is this:

    "String1" === "String2"

    To see if something exists within the string:

    var test1="hello,there,come,never,love,this,and,that,it,is,not,good"

    var findSomething =(test1.indexOf(",love,") > -1)



    In VBScript:

    StrComp("String1", "String2", 1)

    Finding something:

    Dim test1 : test1 ="hello,there,come,never,love,this,and,that,it,is,not,good"

    Dim findSomething : findSomething = InStr(0,test1,",love,",1)
    To iterate is human, to recurse divine. -- L. Peter Deutsch
     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9