[Solved] Type Conversion Error

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
vijaymsc
Posts: 11
Joined: Sun Jan 16, 2011 7:50 pm

[Solved] Type Conversion Error

Post by vijaymsc »

Hi am vijay,
Hi when i using following code

Integer_variable=CInt(Str)

It Shows

"Inadmissible Value or DataType : Overflow" I don know why this is happening... If possible let me clear....

Thanks...
Vijay...
Last edited by Hagar Delest on Thu Jan 20, 2011 9:03 am, edited 1 time in total.
Reason: tagged [Solved].
openoffice 3.2 and Linux Fedora 13
User avatar
Zizi64
Volunteer
Posts: 11362
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Type Conversion Error

Post by Zizi64 »

Hi,

Which string (wich range of numbers) you want to convert?

Please upload an example file here...
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
JohnV
Volunteer
Posts: 1585
Joined: Mon Oct 08, 2007 1:32 am
Location: Kentucky, USA

Re: Type Conversion Error

Post by JohnV »

"Str" is a Basic function which converts a number to a string. Try
s = "1"
n = CInt(s)
or
n = CInt(Str(10))
rudolfo
Volunteer
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Re: Type Conversion Error

Post by rudolfo »

Apart from the CInt() you are not really indicating the programming language that you use.
Assuming it is Basic I reference the Online Help in the section "Macros and Programming"
Online Help: Using Variables wrote:Integer Variables
Integer variables range from -32768 to 32767. If you assign a floating-point value to an integer variable, the decimal places are rounded to the next integer. Integer variables are rapidly calculated in procedures and are suitable for counter variables in loops. An integer variable only requires two bytes of memory. "%" is the type-declaration character.

Code: Select all

Dim nValue As Integer, theString As String
theString = "100000"
nValue = CInt(theString)    ' throws the Overflow runtime error
Use a Long variable and CLong() instead. (just the next paragraph in the online help)

But hey, normally this problem should not lead you to this forum, but instead to start debugging. All the questions with which Zizi64 came up are essential to solve the problem and can be easily answered if you use the debugger of the Basic IDE and step through your code. In the bottom third of the IDE window you can specify variables to watch for. Type [str ] in the text field, hit return and continue stepping through the code. In the section below the variable str will be shown with its current value after each processing step of the macro.
Please read the online help (F1) on the Basic IDE. All the above about debugging is not my wonderful knowledge, but you can find it in the Help of OpenOffice.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
vijaymsc
Posts: 11
Joined: Sun Jan 16, 2011 7:50 pm

Re: Type Conversion Error

Post by vijaymsc »

Hi To all ,
I got cleared with your suggestions... I thank everyone who replied for my post....

Thanks...

vijay
openoffice 3.2 and Linux Fedora 13
User avatar
Tiger42
Posts: 66
Joined: Tue Apr 28, 2015 12:34 pm
Location: India

Re: [Solved] Type Conversion Error

Post by Tiger42 »

Hello,
Same issue here in libreoffie macro

using this code

Code: Select all

Sheet = oDoc.Sheets.getByName("File_source")
Curs = Sheet.createCursor
Curs.gotoEndOfUsedArea(True)
NumRows = Curs.Rows.Count
and when I run macro getting following error

[*]Inadmissible value or data type.Overflow.

Total rows in the file is 47600 and some more so is it any issue regarding numbers of rows ?

Strange thing is that I am using above code in another macro and In that macro has not any issue but in this macro I have data till nearby 31000 rows
Libre Office 5.0/ Open Office /MS Excel/ Windows 7-8
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] Type Conversion Error

Post by Villeroy »

Get some book on Visual Basic. The chapter about data types should be right at the beginning.
In Andrew Pitonyak's book "OpenOffice Macros Explained" it is chapter 3.
http://www.pitonyak.org/oo.php
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply