SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 5 of 5
  1. #1
    Senior Member
    Join Date
    Feb 2012
    Location
    India
    Posts
    203
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Sortinng a string in VBScript

    Can someone give me suggestion that I want to sort a string in VBScript without using in build function.
    Input = "vbscript"
    Output = "bcipstv"

    How should I compare Asc value of each individual string with others and check it. or which is good approach.

    Thanks & Regards,
    Robin Tyagi

  2. #2
    Moderator Joe Strazzere's Avatar
    Join Date
    May 2000
    Location
    USA
    Posts
    13,170
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0

    Re: Sortinng a string in VBScript

    Joe Strazzere
    Visit my website: AllThingsQuality.com to learn more about quality, testing, and QA!

  3. #3
    Advanced Member gencke's Avatar
    Join Date
    Feb 2008
    Location
    Seattle, Washington, United States
    Posts
    531
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0

    Re: Sortinng a string in VBScript

    Patience is like bread I say.... I ran out of that yesterday.

  4. #4
    SQA Knight
    Join Date
    May 2006
    Location
    Playa Del Rey, California, United States
    Posts
    2,592
    Post Thanks / Like
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0

    Re: Sortinng a string in VBScript

    Agree with previous poster, w3schools is awesome for vbscript.

    <font class="small">Code:</font><hr /><pre>
    &lt;script type="text/vbscript"&gt;

    txt="This is a beautiful day!"
    document.write(txt &amp; "&lt;br /&gt;")

    'put chars in an array
    dim arryChars()
    redim arryChars(len(txt))
    for i=1 to len(txt)
    arryChars(i-1) = mid(txt,i,1)
    next

    'quicksort
    for i=0 to UBound(arryChars) step 1
    for j=i to UBound(arryChars) step 1
    if arryChars(i) &gt; arryChars(j) Then
    temp = arryChars(i)
    arryChars(i) = arryChars(j)
    arryChars(j) = temp
    end if
    next
    next

    'convert array back to string.
    sortedString = join(arryChars, "")


    document.write(sortedString &amp; "&lt;br /&gt;")


    &lt;/script&gt;
    </pre><hr />

    Output:
    This is a beautiful day!
    !Taaabdefhiiilsstuuy
    (note the 4 spaces are at the end of the output string)
    David Lai
    SDET / Consultant
    LinkedIn profile

  5. #5
    Senior Member
    Join Date
    Feb 2012
    Location
    India
    Posts
    203
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Sortinng a string in VBScript

    Thanks dlai, really thanks for your effort.


    Thanks

 

 

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 Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 01:38 AM.

Copyright BetaSoft Inc.