SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 8 of 8
  1. #1
    Apprentice
    Join Date
    Oct 2011
    Posts
    34
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Multiple Variables

    Hi,

    Can I create a number of variables during run time based on a numeric value fetched from excel. Say, I fetch 5 from excel and create 5 variables and assign values to them fetched from excel. I ve tried a few ways to do it, but I think Im missing something.

    Regards,
    Madhusudhan

  2. #2
    Member
    Join Date
    Dec 2010
    Location
    Istanbul
    Posts
    292
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Multiple Variables

    Of course you can make it with for or while loops.

    Can you post the code maybe I can help you.
    I look serious because I am serious.

  3. #3
    Member
    Join Date
    Apr 2012
    Location
    Mumbai, India
    Posts
    71
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Multiple Variables

    Hi,
    You can use dynamic array for this purpose.
    Check the number of variable required and redim your array according to the number of variable.
    Regards,
    Mrinal Nandi

    Follow LinkedIn
    Automation Blog

  4. #4
    Apprentice
    Join Date
    Oct 2011
    Posts
    34
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Multiple Variables

    Function Dynamicvariable()
    Dim MyVarName(2)'No. of variables fetched from excel
    MyVarName(0)="Name"'Names of the variable to be created fetched from excel
    MyVarName(1)="Name1"'Names of the variable to be created fetched from excel
    Dim iCount
    Dim Max
    Max = 1

    For iCount = 0 To Max
    ''Create variable here in each iteration
    Next
    End Function

  5. #5
    Junior Member
    Join Date
    Aug 2011
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Multiple Variables

    i dont know, how your Excel sheet looks... if you want to fetch the value using column header then , use the combination of for loop and select case statement to read values from the excel.i attached the sample excel file(image) to read value from the file use the below code.
    Code:
    DataTable.Import Path
    RowCount = DataTable.GetRowCount
    For i= 1 To RowCount
    DataTable.SetCurrentRow(i)
    Header=DataTable("Variable")

    Select Case Header

    Case "a"

    a=DataTable.Value("Value")

    Case "b"

    b=DataTable.Value("Value")
    End Select

    Next
    Attached Images Attached Images

  6. #6
    Advanced Member
    Join Date
    May 2007
    Posts
    609
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0

    Re: Multiple Variables

    I would suggest using a dictionary object, instead.

    Declare a dictionary, cycle through the data sheet, add each value to the dictionary. If you need to have all the values reset for each iteration, you can use the RemoveAll method on the dictionary before adding the new values.
    Dennis Belew

  7. #7
    Moderator
    Join Date
    Oct 2010
    Location
    Norway
    Posts
    3,265
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0

    Re: Multiple Variables

    [ QUOTE ]
    Say, I fetch 5 from excel and create 5 variables and assign values to them fetched from excel.

    [/ QUOTE ]

    Not sure what you are trying. But my guess is this.

    strvariable = DataTable("YourVariable", "Action1")
    strvalue = DataTable("YourValue", "Action1")

    strVariablePart = strvariable
    strEquals = "="
    strQuotes = """"
    strValuePart = "" & strvalue & ""

    Execute strVariablePart & strEquals & strQuotes & strValuePart & strQuotes
    Rajkumar

  8. #8
    Member
    Join Date
    Nov 2006
    Location
    Yorkshire
    Posts
    53
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Multiple Variables

    Another approach would be to use a Data Dictionary:

    'Create a dictionary
    Set dVariablesList = CreateObject("Scripting.Dictionary")

    'Populate the dictionary
    dVariablesList.Add "Company", "HP"
    dVariablesList.Add "Tool", "QuickTest Pro"
    dVariablesList.Add "Website", "LearnQTP"
    dVariablesList.Add "Country", "India"

    'Get a dictionary value
    sCompany = dVariablesList("Company")
    Jonathan

 

 

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 8.33%
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 05:31 AM.

Copyright BetaSoft Inc.