Micro Focus QTP (UFT) Forums
issue in data type in QTP - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: issue in data type in QTP (/Thread-issue-in-data-type-in-QTP)



issue in data type in QTP - galstar - 10-26-2010

Hi,

I am facing an issue in QTP script.
I have a variable 'a' which contains a value of integer type.
Now i am adding this value in datasheet as
Code:
datatable.value("name",1)=a
but the value of 'a' is getting entered as a string, i want it to enter as integer.

Plz anybody help me out to resolve this.

Regards,
Galstar


RE: issue in data type in QTP - MVChowdary - 10-26-2010

Use the CInt function. can you tell me what is the value are you using


RE: issue in data type in QTP - KVK - 10-27-2010

Hi Galstar,

How are you entering value into the variable "a" ?

If you do it the below way, if will take as string

a = "123"

If you do it in the below way, it will take as integer

a = 123

Correct you code accordingly and let me know if it works

Thanks
Vinod


RE: issue in data type in QTP - galstar - 10-27-2010

Hi Vinod,

Actually,i am accessing a value of price from DB.and that returns 29.
but the value in DB is 29.00.I want it same as 29.00.
and then saving that value to 'a'.Then i thought to change the datatype of column of datasheet to number so that assigned value 29 to datasheet get changed to 29.00.
value of 'a' is integer but when i am assigning it to datasheet it is behaving as string.Due to this when entered in datasheet it is not getting changed to 29.00.Sad

Please tell me the solution or any other way to peform it.

Regards,
Galstar


RE: issue in data type in QTP - KVK - 10-27-2010

Hi Galstar,

You have to change the data type of the datatable manually, here are steps,

1.Select the column of the datatable and right click
2. Click on Format and Custom Number--> Select Type as "0.00" and click on OK

There is another way to avoid this manually by entering the data as ="29.00" in the datatable cell. check the below code

Code:
DataTable.Value(2,1) = "="&chr(34)&"29.00"&chr(34)

Let me know if this works for you

Thanks
Vinod


RE: issue in data type in QTP - nandu - 11-19-2010

Hi..

if Data table contains a value like 29 => it treats as String 29
you need to add single Quotation preceeding to 29 like '29 then it treats as numeric 29 in Data table..

This is how Data table functioning with Numbers..