SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 9 of 9
  1. #1
    Junior Member
    Join Date
    Feb 2009
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    how to use split value in a conditional statement

    I have retrieved property of an webelement as below:
    Install_schedule = Browser("Official").Page("Installation").WebElemen t("html tag:=DIV","class:=Pending","html id:=dateSelected").GetROProperty("innerhtml")

    It gives value as “october 12 2010”. Then I am splitting by space (“ “) and storing the values in a container “Install_split”.
    Install_split=Split(Install_schedule, " ")
    Thus ,
    Install_split(0)=October
    Install_split(1)=12
    Install_split(2)=2010
    Now I am trying to use the split value in conditional statements and it fails.
    “If Instr(Con_schedule, Install_split(0)) >0 Then…….”
    (where , Con_schedule = 12 October 2010 )
    Then I thought it might be an issue with handling with regular expression. S o I tried with some modification but it failed again.
    Can anyone help me to use the split value in the conditional statement?

    Thanks a lot.

  2. #2
    Member millersi's Avatar
    Join Date
    Jun 2010
    Location
    Australia, Sydney
    Posts
    192
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to use split value in a conditional statement

    Not sure what you mean by it fails, gives an error or does not match?

    Either way try:

    If InStr(1, Con_schedule, Install_split(0), 1) Then

    The first 1 - tells it to start looking from the first character
    The second 1 - to use a case insensitive text comparison

    This link will explain it better: http://www.devguru.com/technologies/vbscript/13934.asp
    Cheers
    Bear

  3. #3
    Member
    Join Date
    Jun 2008
    Posts
    220
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to use split value in a conditional statement *DELETED*

    Post deleted by DenisJ
    I don't build Software but I make them work better, Testing is a Passion

  4. #4
    Member millersi's Avatar
    Join Date
    Jun 2010
    Location
    Australia, Sydney
    Posts
    192
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to use split value in a conditional statement

    No Selvamahesh has the 'Actucal String' and 'Compare String' the correct way round

    InStr([start, ]stringtosearch, stringtofind [, compare])
    Cheers
    Bear

  5. #5
    Junior Member
    Join Date
    Feb 2009
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to use split value in a conditional statement

    Thanks.

    i think the problem is defining "Install_split(0)". QTP takes "Install_split(0)" literally as regular expression. But I want the QTP to consider as Install_split(0), Install_split(1)...
    I guess it is a problem with regular expression. But i dont know how to solve.any ideas?

    And
    I just tried giving "Install_split(0)="Sun" and executed only that line. I am getting 'type mismatch' error "Install_split(0).

  6. #6
    Moderator
    Join Date
    Jan 2007
    Location
    Pittsburgh, PA
    Posts
    2,497
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to use split value in a conditional statement

    Regular expressions are not directly supported in logical conditions.

    Here in this case Split function is returning a string and you are comparing that against number.

  7. #7
    Moderator
    Join Date
    Jan 2007
    Location
    Pittsburgh, PA
    Posts
    2,497
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to use split value in a conditional statement

    Oops... the problem is with capital "O" v/s small "o"

    October v/s october.

    Use lcase function.

  8. #8
    Junior Member
    Join Date
    Feb 2009
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to use split value in a conditional statement

    TReddy,
    I have clear that lcase issue using "..If InStr(1, Con_schedule, Install_split(0), 1).."

    QTP accepts "Install_split(0)" only for msgbox as "msgbox Install_split(0)" .Otherthan that it throws error message as type mismatch.

  9. #9
    Member
    Join Date
    Nov 2009
    Posts
    93
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to use split value in a conditional statement

    Its working for me...

    Con_schedule = "12 October 2010"
    Install_split = Split("october 12 2010", " ")
    If Instr(1, LCase(Con_schedule), LCase(Install_split(0)), 1) > 0 Then
    Msgbox "Hi"
    End If

    Dislpays "Hi"
    Chinta Praveen Kumar
    chintapraveen@gmail.com
    Sr.Programmer
    <font color="green">A SQL query walks into a bar. He approaches two tables and says, "Mind if I join you?"</font> [img]/images/graemlins/grin.gif[/img]

 

 

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 9.38%
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 09:53 AM.

Copyright BetaSoft Inc.