Thanks:  0
Likes:  0
Dislikes:  0

# Thread: How to concvert a double value to an integer value

1. ## How to concvert a double value to an integer value

QTP reads in my intMisc value (531290270143859) from a spreadsheet as a double. I keep getting an Overflow cInt error.

But i need the value to be an integer

I tied :
intMisc = cInt(intMisc)qand
intMisc = cLng(intMisc) but no luck.

Should I set the intMisc to a string value? Not sure how this goes either.

I have looked online for a reference on how to convert values. I havent fount anything that worked.

2. ## Re: How to concvert a double value to an integer value

CLng the value must be a number between -2147483648 and 2147483647 and CInt the value must be a number between -32768 and 32767. Is the cell in Excel formatted as a number?

3. ## Re: How to concvert a double value to an integer value

That number is way too large to be an integer. Integers have to be between -32,767 and 32,767.

Long is in the -2,147,483,648 to 2,147,483,647 range. So it looks like your value of 531,290,270,143,859 won't fit that either.

What are you ultimately trying to do to the value? Add to it? Subtract from it? Or just reference it?

4. ## Re: How to concvert a double value to an integer value

I had to work with QTP and large numbers, so I connected to EXCEL and then used formulas. I forget exactly how I did it.

QTP and VBScript did not like the gigantic numbers or accurate decimals, so I did the work in MS Excel.

5. ## Re: How to concvert a double value to an integer value

@Greg, yea I saw that about integers, etc. I tried cLng and others too.

@Dennis, I am trying to use the number from a speadsheet and input the value into a edit box. But since the number is so long, I am getting the overflow error. I tried to force the value to be a string, but it too crashed with an overflow error. Unless I did not convert correctly.

@bklabel, thx for the info

6. ## Re: How to concvert a double value to an integer value

Why are you trying to convert it in the first place rather than just work with the double?

Is the overflow error you're referring to coming from your application, not qtp? Just need to report that to your application developers if it's a valid number for the use case.

7. ## Re: How to concvert a double value to an integer value

What happens if you put an apostrophe in front, making it text in Excel? (i.e. '531290270143859)

8. ## Re: How to concvert a double value to an integer value

@NoUseForAName - I need to place the value into a text box. I have the value wset as qa Double, but i get the P tries to grab the value.

@Greg - Now, I tried to set the text box with the apostrophe in front of the number, but I get a text box message indicating the special character is not allowed.

9. ## Re: How to concvert a double value to an integer value

Greg was referring to having the apostrophe in excel so that it is treated as text there.

What method are you using to retrieve the value from Excel? There is where you should be pulling it in as a text string rather than converting it.

[ QUOTE ]
I have the value wset as qa Double, but i get the P tries to grab the value.

[/ QUOTE ]
?

10. ## Re: How to concvert a double value to an integer value

Sorry for my bad typing. Im always in a hurry.

@Greg - thx... to pull in my value I use:

Set objExcel = CreateObject("Excel.application") 'Open Microsoft Excel object
Set objWorkbook = objExcel.WorkBooks.Open(FilePathTestData)'Open Excel xls
Set objDriverSheet = objWorkbook.Worksheets("Sheet1") 'Set Sheet1
objExcel.Visible = True

If ENV = objDriverSheet.Cells(r,1).Value Then
SectionName = objDriverSheet.Cells(r,3).Value
...

How do I set the Value to read a text variable?
Or
Do I just place ' in front of the number in the Excel cell? (as in '1234567890123456789

#### 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.