Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
issue in data type in QTP
#1
Solved: 11 Years, 3 Months, 4 Weeks ago Exclamation 
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
Reply
#2
Solved: 11 Years, 3 Months, 4 Weeks ago
Use the CInt function. can you tell me what is the value are you using
Reply
#3
Solved: 11 Years, 3 Months, 4 Weeks ago
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
Reply
#4
Solved: 11 Years, 3 Months, 4 Weeks ago
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
Reply
#5
Solved: 11 Years, 3 Months, 4 Weeks ago
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
Reply
#6
Solved: 11 Years, 3 Months, 4 Weeks ago
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..
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Different Type of Dropdown Selector zunebuggy 6 3,396 05-01-2018, 06:46 PM
Last Post: zunebuggy
  On Saving Script in QTP 11 my Global Data Sheet data is removed M Adnan Iftikhar 0 2,173 06-02-2015, 09:19 PM
Last Post: M Adnan Iftikhar
  cannot use the type method on object and submit is not working jove1776 5 8,813 01-27-2015, 10:08 PM
Last Post: Parke
  How to import .xlsx file type to QTP qtped 3 6,656 03-27-2014, 01:33 PM
Last Post: Ankur
  type mismatch error in QTP QAlearningQTP 1 7,122 02-04-2014, 08:14 AM
Last Post: QAlearningQTP

Forum Jump:


Users browsing this thread: 1 Guest(s)