In QTP scripting, many times you need to compare 2 values.
When you compare the values, it is necessary that both variables should have same data type.
Below functions are used to convert the data type of variable.
Example -
str = "10"
print typename(str)
str = cint(str)
'Convert the string into integer data type
print typename(str)
More examples on data type conversions are at date and string conversions
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.
When you compare the values, it is necessary that both variables should have same data type.
Below functions are used to convert the data type of variable.
- cint - converts the expression into integer sub data type
- cdbl - converts the expression into double sub data type
- clng - converts the expression into long sub data type
Example -
str = "10"
print typename(str)
str = cint(str)
'Convert the string into integer data type
print typename(str)
----------------------------------------------------------------------
----------------------------------------------------------------------
str = "10.2"
print typename(str)
str = cdbl(str)
'Convert the string into double data type
print typename(str)
print typename(str)
str = cdbl(str)
'Convert the string into double data type
print typename(str)
----------------------------------------------------------------------
----------------------------------------------------------------------
str = "108787"
print typename(str)
str = clng(str)
'Convert the string into long data type
print typename(str)
print typename(str)
str = clng(str)
'Convert the string into long data type
print typename(str)
More examples on data type conversions are at date and string conversions
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.
No comments:
Post a Comment
Please Leave your reply. We value your feedback and inputs