[Solved] Type Conversion Error

Keyboard macros or custom scripts

[Solved] Type Conversion Error

Postby vijaymsc » Wed Jan 19, 2011 2:45 pm

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
vijaymsc
 
Posts: 11
Joined: Sun Jan 16, 2011 7:50 pm

Re: Type Conversion Error

Postby Zizi64 » Wed Jan 19, 2011 3:58 pm

Hi,

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

Please upload an example file here...
Tibor Kovacs, Hungary; LO4.4.7, LO5.4.7 on Win7x64Prof.
PortableApps, winPenPack: LO3.3.0-LO6.1.0 and AOO4.1.5
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.
User avatar
Zizi64
Volunteer
 
Posts: 6982
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Type Conversion Error

Postby JohnV » Wed Jan 19, 2011 6:05 pm

"Str" is a Basic function which converts a number to a string. Try
s = "1"
n = CInt(s)
or
n = CInt(Str(10))
JohnV
Volunteer
 
Posts: 1585
Joined: Mon Oct 08, 2007 1:32 am
Location: Kentucky, USA

Re: Type Conversion Error

Postby rudolfo » Thu Jan 20, 2011 3:44 am

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   Expand viewCollapse view
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.
rudolfo
Volunteer
 
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Re: Type Conversion Error

Postby vijaymsc » Thu Jan 20, 2011 8:14 am

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
vijaymsc
 
Posts: 11
Joined: Sun Jan 16, 2011 7:50 pm

Re: [Solved] Type Conversion Error

Postby Tiger42 » Fri Jun 03, 2016 9:09 am

Hello,
Same issue here in libreoffie macro

using this code
Code: Select all   Expand viewCollapse view
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
Tiger42
 
Posts: 67
Joined: Tue Apr 28, 2015 12:34 pm
Location: India

Re: [Solved] Type Conversion Error

Postby Villeroy » Fri Jun 03, 2016 10:23 am

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 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 25556
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 3 guests