SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    22
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    String comparison throws error

    Hi,
    I have prepared the script in VB to compare two strings and it should be display the total matches and mismatches from the strings...but it throws type mismach error

    ////////////////////////
    name1="saravanans"
    name2="sara"
    name1len=len(name1)
    name2len=len(name2)
    same=0
    mismatch=0
    for x=1 to name1len
    u=Mid(name1,x,1)

    for y=1 to name2len
    y=mid(name2,y,1)

    if u=y then
    same=same+1
    else
    mismatch=mismatch+1
    end if
    next
    next

    msgbox same
    msgbox mismatch
    /////////////////////

    Kindly clarify ....Have i made any mistakes...

  2. #2
    Junior Member
    Join Date
    Nov 2011
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: String comparison throws error

    Hi Jasmine,
    I'm not very sure what you want to have as an output from this script. I think you were writing "y" again in the 2nd for loop, so I changed it to another variable "v".

    name1="saravanans"
    name2="sara"
    name1len=len(name1)
    name2len=len(name2)
    same=0
    mismatch=0

    for x=1 to name1len
    u=Mid(name1,x,1)

    for y=1 to name2len
    v=mid(name2,y,1)

    if u=v then
    same=same+1
    else
    mismatch=mismatch+1
    end if
    next
    next

    msgbox same
    msgbox mismatch


    Vipin

  3. #3
    Junior Member
    Join Date
    Apr 2012
    Posts
    22
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: String comparison throws error

    Thank you vipin ...
    My requirement is string comparison output for two strings ...the script shall produce the total matches and mismatches...

 

 

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 11.54%
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 04:16 PM.

Copyright BetaSoft Inc.