Error on a simple function to fill an array plz hlp

Hi guys.
I'm trying to fill in an array with a simple function, here is the code
public class rekener {
    int getal;
    int counter=-1;
    int[] getallen= new int[5];
    StringBuffer buffer= new StringBuffer();
    public void getGetal(int getal){
        this.getal= getal;
        counter++;
        getallen[counter]= getal;
    public String getArray(){
       for(int i: getallen){
           buffer.append(i);
       return buffer.toString();
}i'm calling this function from a console application in this way....
import java.util.Scanner;
class venster{
   public static void main(String args[]){
       int getal;
       rekener rekener= new rekener();
       Scanner input= new Scanner(System.in);
       System.out.println("Voeg toe een nummer A.U.B");
       getal= input.nextInt();
       rekener.getGetal(getal);
       System.out.println("voeg nog een nummer toe");
       getal= input.nextInt();
       rekener.getGetal(getal);
       System.out.println("voeg nog een nummer toe");
       getal= input.nextInt();
       rekener.getGetal(getal);
       System.out.println("voeg nog een nummer toe");
       getal= input.nextInt();
       rekener.getGetal(getal);
       System.out.println("voeg nog een nummer toe");
       getal= input.nextInt();
       rekener.getGetal(getal);
       System.out.println("voeg nog een nummer toe");
       getal= input.nextInt();
       rekener.getGetal(getal);
       String list= rekener.getArray();
       System.out.println(""+list);
}the problem is that the last function "getGetal();" which should deliver the StrinBuffer in a string format, does not do so, but gives me this error
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
        at rekener.getGetal(rekener.java:22)
        at venster.main(venster.java:37)
Java Result: 1the line 22 is this :
getallen[counter]= getal;this makes me think that the function that should fill the array isn't really doing it,
Even if i change the volume of the array to 4 or 6 "even though 5 is the correct ammount since i'm inserting 6 integers", keeps on giving me the same error
Do you now any other solution in order to fill in an array from an external function?
Thank you and have a nice day
Edited by: classboy on Dec 12, 2009 11:01 PM

classboy wrote:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
at rekener.getGetal(rekener.java:22)
at venster.main(venster.java:37)The error message is telling you exactly what's wrong. On linke 22 of rekener.java (should be Rekener--class names conventionally start with uppercase), you are trying to access the 6th element, at index 5, of an array that has at more 5 elements, at indices 0..4
the line 22 is this :
getallen[counter]= getal;
So counter is 5. But getallen has only 5 elements at indices 0..4, or fewer.
this makes me think that the function that should fill the array isn't really doing it, It has nothing to do with whether the array is being "filled." Rather, it's just that the size of the array is less than what you're trying to access.
Even if i change the volume of the array to 4 or 6 "even though 5 is the correct ammount since i'm inserting 6 integers", keeps on giving me the same errorNo idea what you're saying here, but the compiler doesn't lie. You're trying to access an array element that doesn't exist.
Put print statements in your code so you can see what's happening at each step of the way, and figure out what you did to tell it to access elements that don't exist.

Similar Messages

  • Error while creating a simple function, procedure or triger in Oracle8i Lite

    Hi,
    I have Oracle8i Lite release 4.0.
    While creating a simple proceudre/function/trigger on the database, it's throwing the following error:
    create or replace function test return number is
    ERROR at line 1:
    OCA-30021: error preparing/executing SQL statement
    [POL-5228] syntax error
    Here is my sample code.
    create or replace function test return number is
    begin
    return 0;
    end;
    Tried to create the same function in the user SYSTEM too but got the same error message.
    Thanks in advance for the soluton.
    null

    I just started with 8i Lite, but as far as I know 8i Lite does not support PL/SQL code.
    So you have to write your triggers and stored procedures in Java.
    Ciao

  • Error after creating a function using SE37

    Hello friends
    I have created a simple function (remote enabled).
    Syntax check says everything is ok.
    When I try to Activate, I get the following error message.
    Program SAPLZBAPI_CONFIGDNA_INSERT
    REPORT/PROGRAM statement missing, or program type is I (INCLUDE).
    The name of the function that I have created is ZBAPI_CONFIGDNA_INSERT.
    However, it is complaining about a program SAPLZBAPI_CONFIGDNA_INSERT.
    I have created BAPIS before and so I am sure that the steps I have created are ok.
    I even tried creating the same BAPI with different names and still the same problem.
    Any feedback will be greatly appreciated.
    Thanks
    Ram

    in the TOP Include the statement
    FUNCTION-POOL (<b>Name of function Group</b>).
    is missing.
    to Reach to th eexact point.
    to to attibutes tab of your FM
    double click on Program Name.
    double click on include ending with TOP.
    Declare the statement in the TOP include.
    amandeep.

  • Using simple functions in JSP

    Hi to all,
    I would to use simple functions in my jsp page.
    I 've created the function with the tags <%! ... %>
    My problem is that i don't succed to call there from the page.
    How i can to do ?
    I've tried also with java beans but i'm not very clever with there also so i don't can to go forward !!!
    Please help me. thanks

    Hi, a new problem rises now.
    the problem is into the method ctr_data().
    Under i put the jsp code and the error:
    Anyone can see where is the error please?
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@page import= "java.sql.*,  java.lang.*" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <title>Progetto Sofia - Registrazione utente</title>
    </head>
    <%!
    public boolean ctr_lunghezza(String s1){
        if (s1.length() == 0) return false;
        return true;
    %>
    <%!
    public boolean isLeapYear(int year) {
           if (year%400 == 0)  return true;
           if ((year%4 == 0) && (year%100 != 0))return true;
           return false;
    %>
    <%!
    public boolean ctr_data (String gg, String mm, String aa){
        int anno = Integer.valueOf(aa).intValue();
        int mese = Integer.valueOf(mm).intValue();
        int giorno = Integer.valueOf(gg).intValue();
        if ((gg.length() == 0) || (mm.length() == 0) || (aa.length() == 0))
            return false;
        if ((anno < 1905) || (anno > 2005))
            return false;
        if (mese == 2){
            if (isLeapYear(anno)){
                if (giorno > 29) return false;
            }else{
                if (giorno > 28) return false;
        if ((mese == 11) || (mese == 4) || (mese == 6) || (mese == 9)){
            if (giorno == 31) return false;
        return true;
    %>
    <%
    int flag = 0;
    String risposta = "";
    String temp ="";
    temp = (request.getParameter("nome_utente")!=null)?request.getParameter("nome_utente") :"";
    if (ctr_lunghezza (temp) == false){
       risposta = risposta.concat("Attenzione --- Riempire il campo: Nome\n");
       flag++;
    temp = (request.getParameter("cognome_utente")!=null)?request.getParameter("cognome_utente"):"";
    if (!ctr_lunghezza (temp)){
        risposta = risposta.concat("Attenzione --- Riempire il campo: Cognome\n");
        flag++;
    String gg1 = (request.getParameter("giorno_n_utente")!=null)?request.getParameter("giorno_n_utente"):"0";
    String mm1 = (request.getParameter("mese_n_utente")!=null)?request.getParameter("mese_n_utente"):"0";
    String aa1 = (request.getParameter("anno_n_utente")!=null)?request.getParameter("anno_n_utente"):"0";
    if (!ctr_data(gg1, mm1, aa1)){
        risposta = risposta.concat("Attenzione --- Data di nascita non corretta\n");
        flag++;
    temp = (request.getParameter("luogo_n_utente")!=null)?request.getParameter("luogo_n_utente"):"";
    if (!ctr_lunghezza (temp)){
        risposta = risposta.concat("Attenzione --- Riempire il campo: Luogo di nascita\n");
        flag++;
    temp = (request.getParameter("res_utente")!=null)?request.getParameter("res_utente"):" ";
    if (temp == "Seleziona"){
        risposta = risposta.concat("Attenzione --- Selezionare il Comune di Residenza\n");
        flag++;
    temp = (request.getParameter("ind_utente")!=null)?request.getParameter("ind_utente"):" ";
    if (!ctr_lunghezza(temp)){ 
        risposta = risposta.concat("Attenzione --- Riempire il campo Indirizzo\n");
        flag++;
    %>and this is the error msg:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: For input string: ""
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    java.lang.NumberFormatException: For input string: ""
         java.lang.NumberFormatException.forInputString(Unknown Source)
         java.lang.Integer.parseInt(Unknown Source)
         java.lang.Integer.valueOf(Unknown Source)
         org.apache.jsp.progetto.w2.web.Reg_005futente_jsp.ctr_data(org.apache.jsp.progetto.w2.web.Reg_005futente_jsp:27)
         org.apache.jsp.progetto.w2.web.Reg_005futente_jsp._jspService(org.apache.jsp.progetto.w2.web.Reg_005futente_jsp:122)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

  • Error message: 1021: Duplicate function definition.

    Hi All,
    First let me start by saying that I know next to nothing about Flash.  I have inherited a website maintenance project that has a Flash rotating image banner.  I have managed to get the images to fade-in and fade-out correctly, but now I need to make these images clickable - linking images to pages in the website.  I have read many posts here and have reviewed the video tutorials.  I have been able to get the first image clickable using this AS3 action:
    mars_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler);
    function buttonClickHandler(event:MouseEvent) :void {
            navigateToURL(new URLRequest("http://somewebsite/mars.php"));
            trace("I'm clicked");
    However, when I attempt to make another image clickable by using a different instance of a button I get the error message:
    1021: Duplicate function definition.
    I have a separate instance of a button with this AS3 action:
    jupiter_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler);
    function buttonClickHandler(event:MouseEvent) :void {
            navigateToURL(new URLRequest("http://somewebsite/jupiter.php"));
            trace("I'm clicked");
    Obviously I'm not understanding how I'm supposed to do this so that I don't create a duplicate function definition.  Any help would be most appreciated.

    excuse me , I have a question i hope that you help .. ( im new in here )
    we were asked to create an interactive application on flash in two languages..
    so i created two different fla files same exact codings ... i was wondering how can i combine them so the viewer can be able to choose the language from a button ?
    when i try to combine them i get lots of errors of duplications in the actionscript
    PS : MY MAIN PAGE INCLUDES A CAROUSEL with images ..
    I was thinking of saving one of the fla  as a movie and then add it some how to the second fla and combine it with a button but i can't figure it how..
    i hope i was clear enough.. but is there any possibility to help me please ?!
    when i tend to change names or something it creates error.. ( IM NOT A PRO IN AS3 ) and when i dublicate the scenes it give duplication errors.. WHAT IS THE SOLUTION ??
    this is the code of the actionscript in the main page.. ( the carousel's code i took from someone ) and i used it on my project
    import com.ccanvas.carousel.*;
    var centerX:Number = stage.stageWidth/4;
    var centerY:Number = stage.stageHeight/4;
    var carc:Carousel = new Carousel(centerX, centerY, 256, 75, "icons.xml");
    carc.addTooltip(new tooltip); // use 'tooltip' movieclip for item tooltip
    addChild(carc); // add carousel to stage
    function down(event:MouseEvent):void {
    trace(event.currentTarget.toolText); // simple click interaction
    function destroyCarousel(event:MouseEvent):void {
    carc.destroy(); // remove all item in carousel as well as tooltip
    function removeNextItem(event:MouseEvent):void {
    if(carc.numOfItems > 2) {
      carc.removeItem(2); // remove the item next to the remove item icon
    create.addEventListener("mouseDown", createCarousel);
    function createCarousel(event:MouseEvent):void {
    if(carc.CREATED == false) {
      // recreate the carousel
      carc = new Carousel(centerX, centerY, 256, 75, "icons.xml");
      carc.addTooltip(new tooltip);
      addChild(carc);
    }/* Click to Go to Scene and Play
    Clicking on the specified symbol instance plays the movie from the specified scene and frame.
    Instructions:
    1. Replace "Scene 3" with the name of the scene you would like play.
    2. Replace 1 with the frame number you would like the movie to play from in the specified scene.
    Tools_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene);
    function fl_ClickToGoToScene(event:MouseEvent):void
    MovieClip(this.root).gotoAndPlay(1, "Toolse");
    }/* Click to Go to Scene and Play
    Clicking on the specified symbol instance plays the movie from the specified scene and frame.
    Instructions:
    1. Replace "Scene 3" with the name of the scene you would like play.
    2. Replace 1 with the frame number you would like the movie to play from in the specified scene.
    games_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToGames);
    function fl_ClickToGoToGames(event:MouseEvent):void
    MovieClip(this.root).gotoAndPlay(1, "Gamese");
    }/* Click to Go to Scene and Play
    Clicking on the specified symbol instance plays the movie from the specified scene and frame.
    Instructions:
    1. Replace "Scene 3" with the name of the scene you would like play.
    2. Replace 1 with the frame number you would like the movie to play from in the specified scene.
    Identity_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToIdentity);
    function fl_ClickToGoToIdentity(event:MouseEvent):void
    MovieClip(this.root).gotoAndPlay(1, "Identitye");
    }/* Click to Go to Scene and Play
    Clicking on the specified symbol instance plays the movie from the specified scene and frame.
    Instructions:
    1. Replace "Scene 3" with the name of the scene you would like play.
    2. Replace 1 with the frame number you would like the movie to play from in the specified scene.
    Reviews_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_13);
    function fl_ClickToGoToScene_13(event:MouseEvent):void
    MovieClip(this.root).gotoAndPlay(1, "Reviewse");
    }/* Click to Go to Scene and Play
    Clicking on the specified symbol instance plays the movie from the specified scene and frame.
    Instructions:
    1. Replace "Scene 3" with the name of the scene you would like play.
    2. Replace 1 with the frame number you would like the movie to play from in the specified scene.
    Facts_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_20);
    function fl_ClickToGoToScene_20(event:MouseEvent):void
    MovieClip(this.root).gotoAndPlay(1, "Factse");

  • Error Accessing an Oracle Function

    Hi There,
    I am trying to access an oracle function and getting an
    error.
    CREATE OR REPLACE FUNCTION simple RETURN VARCHAR2 IS
    BEGIN
    RETURN 'Simple Function';
    END simple;
    <cfstoredproc procedure="simple" datasource="MySource"
    returnCode ="no">
    <CFPROCRESULT name="simple_function">
    </cfstoredproc>
    Error:
    Error Executing Database Query. [Macromedia][SequeLink JDBC
    Driver][ODBC Socket][Oracle][ODBC]Syntax error or access violation.
    I do have access to this function. I tried it from SQL Plus
    and it works fine.
    any help in this will be highly appreciated.
    Regards,

    As per Adam Cameron advice, I changed my SQL function:
    CREATE OR REPLACE FUNCTION simple RETURN VARCHAR2 IS
    a varchar2(10) := '';
    BEGIN
    select 'Simple' into a from dual;
    Return a;
    END simple;
    As per paross1 advice, I changed my code to:
    <cfstoredproc procedure="simple" datasource="MySource"
    returnCode ="yes">
    <CFPROCRESULT name="simple_function">
    </cfstoredproc>
    I am still getting the following error:
    Error Executing Database Query. [Macromedia][SequeLink JDBC
    Driver][ODBC Socket][Oracle][ODBC]Syntax error or access violation.
    The error occurred on line 53.
    Any advice will be highly appreciated.

  • Help With Simple Function

    I was wondering if someone could help me out with a simple function I'm trying to create. I'm kind of new to functions in oracle and I don't know the exact syntax or what it expects from me. I would appreciate it if someone could look at this and point out what I'm doing wrong.
    CREATE OR REPLACE FUNCTION freshman_status_term(
    pidm IN varchar2
    RETURN varchar2 IS term
    BEGIN
    SELECT sgbstdn_term_code_eff INTO term
    FROM sgbstdn
    WHERE sgbstdn_pidm = pidm
    AND sgbstdn_styp_code = 'F'
    AND sgbstdn_stst_code = 'AS'
    RETURN term;
    END freshman_status_term;
    The goal of the function is to find out the term for when a student is listed as a freshman. I keep getting errors though, so something must be wrong with it. Any help is appreciated. Thanks.

    Sven W. wrote:
    >
    My code looked exactly like that minus the exception part when I got the error before.Please post the code that you used and the full error message that you got.CREATE OR REPLACE FUNCTION freshman_status_term(
    pidm IN varchar2
    RETURN varchar2
    IS
    term sgbstdn.sgbstdn_term_code_eff%TYPE;
    BEGIN
    SELECT sgbstdn_term_code_eff INTO term
    FROM sgbstdn
    WHERE sgbstdn_pidm = pidm
    AND sgbstdn_styp_code = 'F'
    AND sgbstdn_stst_code = 'AS'
    RETURN term;
    END freshman_status_term;
    SELECT freshman_status_term ('216520') FROM dual;
    Error: PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
    ( - + ; case mod new not null <an identifier>
    The error is highlighted right after the BEGIN statement
    Edited by: user10548103 on Nov 6, 2008 8:53 AM

  • Need help in simple function

    Hi,
    i am using sql developer to write a simple function .which need to get job details by using employ number
    ..below is the function
    CREATE OR REPLACE
    FUNCTION Q_JOB(empno1 in emp.empno%type) RETURN VARCHAR2 AS
    job1 varchar2(100);
    BEGIN
    select job into job1 from
    emp where empno=empno1;
    dbms_output.put_line('job :'||job1);
    RETURN job1;
    END Q_JOB;
    when i am trying to run this using command
    execute q_job(7369);
    i am getting folowing error..
    PL/SQL: Statement ignored
    06550. 00000 - "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:
    can any one tell whats exact problem is?

    You can use execute only for procedures, not functions.
    You have different possibilities:
    * If you like issuing the statement from a worksheet, use an anonymous block:
    DECLARE
      v_job  emp.job%type;
    BEGIN
      v_job = q_job(7369);
    END;
    / * Alternatively, use your function in SQL:
    SELECT q_job(7369) FROM DUAL; * For editing and testing your PL/SQL code, sqldev has very cool features: editor, compiler and debugger.
    Under the Functions node under your connection, you'll find your function: right-click and Edit it. Just above your code you have a mini-toolbar to Compile your code, Run or Debug it. A lot more on this inside the Help topics.
    Using the last 2 possibilities will provide you the returned value, so using dbms_output in your function isn't even necessary.
    Have fun,
    K.

  • Pass TestStand error type directly into function parameter

    Hi,
    I am using TestStand 4 and Labwindows CVI 8.5.
    I wonder if it is possible to pass Standard Step error type into CVI function parameters.
    I think it would be more simple to pass one parameter instead of passing Error code, Error occurred state and Error message into function prototype.
    I tried to use tsErrorDataType struct defined into tsutil.h into my function prototype.
    In TestStand, I pass Step error type into function parameter but it does not work.
    TestStand displays an error meaning parameters does not match function prototype.
    Thank you for your help.

    Hi Tartempion,
    In order to pass the TestStand Error Container as one parameter to a function in a CVI DLL, you must use a struct that is typedef'ed and create an .fp file that is included as a type library for the DLL. When you create a .fp file to add to a DLL, the DLL will not build unless all structs/enums are typedef'ed. Thus, I wouldn't advise using the tsutil.h because you would have to go through and typedef every single struct and enum in the header file.
    Instead, you can simply create a typedef'ed struct in your projects header file and create an .fp file with the struct specified as a data type. Then in TestStand, when you call the function you would need to ensure that the parameter is of Category "C Struct", and type "Error". The attached zip file contains a CVI 8.5 project that demonstrates this along with a TestStand 4.0 sequence file that demonstrates how to pass the parameter to the function by reference. In case you run into trouble creating the .fp file please refer to the following KnowledgeBase. The instructions are for enums but easily correspond to structs as well:
    TestStand and LabWindows/CVI Enumeration Data Types
    Hope this helps!
    Manooch H.
    National Instruments
    Attachments:
    PassTSError.zip ‏19 KB

  • Error 2147500037 returned by function MAPIResolveName

    I am getting this error when i am sending  a mail
    MAPI Destination
    Error 2147500037 returned by function <MAPIResolveName>
    its Crystal Report 8.5 with SP3
    Windows Server 2008 R2 Standard
    Windows LIve Mail
    Please suggest

    Upgrade to Crystal Reports 2008 SP 3 and install [Fix Pack 3.5|https://smpdl.sap-ag.de/~sapidp/012002523100006341722011E/cr2008fp35.exe] and then it supports Windows Office 2007 Extended MAPI API's. Microsoft deprecated the Simple MAPI API's in in Office 2007 and above.
    Not supported in CR 8.5, it is 10 years old. Only other option is to ask Microsoft to add the simple MAPI API's back into their new Office Products that use MAPI.
    Thank you
    Don

  • Error in running a function to convert coordinates in degrees to decimal for EXCEL VBA

    For your information, I have 3 cross-posts regarding this question - and all I can said there is still no firm solution regarding this error.
    1) http://stackoverflow.com/questions/27634586/error-in-running-a-function-to-convert-coordinates-in-degrees-to-decimal-for-exc/27637367#27637367
    2) http://www.mrexcel.com/forum/excel-questions/826099-error-running-function-convert-coordinates-degrees-decimal-excel-visual-basic-applications.html#post4030377 
    3) http://www.excelguru.ca/forums/showthread.php?3909-Error-in-running-a-function-to-convert-coordinates-in-degrees-to-decimal-for-EXCEL-VB&p=16507#post16507
    and the story of the error is as below:
    Currently I am working on VBA excel to create a widget to verify coordinates whether it lies under the radius of ANOTHER predefined and pre-specified sets of coordinates.
    In the module, I want to convert the coordinates from degrees to decimal before doing the calculation - as the formula of the calculation only allow the decimal form of coordinates.
    However, each and every time I want to run the macros this error (Run-time error '5', invalid procedure call or argument) will appear. Then, the debug button will bring me to below line of coding:
    degrees = Val(Left(Degree_Deg, InStr(1, Degree_Deg, "°") - 1))
    For your information, the full function is as below:
    Function Convert_Decimal(Degree_Deg As String) As Double
    'source: http://support.microsoft.com/kb/213449
    Dim degrees As Double
    Dim minutes As Double
    Dim seconds As Double
    Degree_Deg = Replace(Degree_Deg, "~", "°")
    degrees = Val(Left(Degree_Deg, InStr(1, Degree_Deg, "°") - 1))
    minutes = Val(Mid(Degree_Deg, InStr(1, Degree_Deg, "°") + 2, _
    InStr(1, Degree_Deg, "'") - InStr(1, Degree_Deg, "°") - 2)) / 60
    seconds = Val(Mid(Degree_Deg, InStr(1, Degree_Deg, "'") + _
    2, Len(Degree_Deg) - InStr(1, Degree_Deg, "'") - 2)) / 3600
    Convert_Decimal = degrees + minutes + seconds
    End Function
    Thank you.
    Your kind assistance and attention in this matter are highly appreciated.
    Regards,
    Nina.

    You didn't give an example of your input string but try the following
    Sub test()
    Dim s As String
    s = "180° 30' 30.5""""" ' double quote for seconds
    Debug.Print Deg2Dec(s) ' 180.508472222222
    End Sub
    Function Deg2Dec(sAngle As String) As Double
    Dim mid1 As Long
    Dim mid2 As Long
    Dim degrees As Long
    Dim minutes As Long
    Dim seconds As Double ' or Long if only integer seconds
    sAngle = Replace(sAngle, " ", "")
    mid1 = InStr(sAngle, "°")
    mid2 = InStr(sAngle, "'")
    degrees = CLng(Left$(sAngle, mid1 - 1))
    minutes = CLng(Mid$(sAngle, mid1 + 1, mid2 - mid1 - 1))
    seconds = Val(Mid$(sAngle, mid2 + 1, 10)) ' change 10 to 2 if only integer seconds
    Deg2Dec = degrees + minutes / 60 + seconds / 3600
    End Function
    As written the function assumes values for each of deg/min/sec are included with unit indicators as given. Adapt for your needs.
    In passing, for any work with trig functions you will probably need to convert the degrees to radians.

  • SSRS countrow Aggregate error(Aggregate and lookup functions cannot be used in query parameter expressions.)

    Below expression works fine with text box but gives error in dataset expression.
    ="SET FMTONLY OFF select  "+ join(Parameters!Column.Value,",") +" FROM pamcustom.dbo.vw_HFL_HFD_HotfileData INNER JOIN pamcustom.dbo.HFL_HFB_HotFileBatch  on BatchID = HFB_intBatchID where BatchID ="+Parameters!BatchId.Value+"
    and "+Parameters!cmbTranType.Value+" "+ iif(CountRows("DS_Aml_Mnr_Iss_Desc")=Parameters!Mnr_Iss_Desc.count," "," and aml_mnr_iss_desc in "+"('" & join(Parameters!Mnr_Iss_Desc.Value,"','")
    & "')")+iif(CountRows("ds_ReportingCategory")=Parameters!ReportingCategory.count," "," and ReportingCategory in "+"('" & join(Parameters!ReportingCategory.Value,"','") & "')")+iif(CountRows("ds_NAICSubGroup")=Parameters!NAICSubGroup.count,"
    "," and naicsubgroup in "+"('" & join(Parameters!NAICSubGroup.Value,"','") & "')")+iif(CountRows("ds_PortTrading")=Parameters!PortTrading.count," "," and porttrading in "+"('"
    & join(Parameters!PortTrading.Value,"','") & "')")+iif(CountRows("ds_GL_LE")=Parameters!GL_LE.count," "," and gl_le in "+"('" & join(Parameters!GL_LE.Value,"','") &
    "')")+iif(CountRows("ds_coagroup")=Parameters!cmbCoaGrp.count," "," and coagroup in "+"('" & join(Parameters!cmbCoaGrp.Value,"','") & "')")+iif(CountRows("Portfolio")=Parameters!cmbPort.count,"
    "," and portfolio in "+"('" & join(Parameters!cmbPort.Value,"','") & "')")+IIf(IsNothing(Parameters!txtSecID.Value)," "," and secid in ('"+Replace(Parameters!txtSecID.Value,",","','")+"')")+iif(IsNothing(Parameters!minPortFilter.Value)
    and IsNothing(Parameters!MinPort.Value)," "," and portfolio "+Parameters!minPortFilter.Value+Parameters!MinPort.Value)+iif(IsNothing(Parameters!maxPortFilter.Value) and IsNothing(Parameters!MaxPort.Value)," ","
    and portfolio "+Parameters!maxPortFilter.Value+Parameters!MaxPort.Value)+iif(IsNothing(Parameters!minCoaFilter.Value) and IsNothing(Parameters!txtMinCoa.Value)," "," and portfolio "+Parameters!minCoaFilter.Value+Parameters!txtMinCoa.Value)+iif(IsNothing(Parameters!maxCoaFilter.Value)
    and IsNothing(Parameters!txtMaxCoa.Value)," "," and portfolio "+Parameters!maxCoaFilter.Value+Parameters!txtMaxCoa.Value)
    I guess the error " Aggregate and lookup functions cannot be used in query parameter expressions." is because I am using CountRow to ensure that if all values of multi select all selected i will not use that filter in where clause.
    Pls. guide...

    Hi, Include your parameter total count in the dataset for parameter and instead of using countrows() function use the count from dataset in the expression.
    Hope this helps.........
    Ione

  • Error While uploading the Function and Function_BP

    Hello,
    I am getting the following error while uploading the Functions and Funtions_BP using the Rule Upload functions.
    com.virsa.cc.comp.Function_upload.onActionUploadFunc(Function_upload.java:302) com.virsa.cc.comp.wdp.InternalFunction_upload.wdInvokeEventHandler(InternalFunction_upload.java:150) com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87) com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67) com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doHandleActionEvent(WindowPhaseModel.java:420) com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:132) com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:335) com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:143) com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:321) com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:713) com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:666) com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:250) com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:149) com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62) com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:53) javax.servlet.http.HttpServlet.service(HttpServlet.java:760) javax.servlet.http.HttpServlet.service(HttpServlet.java:853) com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401) com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266) com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:386) com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:364) com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:1039) com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:265) com.sap.engine.services.httpserver.server.Client.handle(Client.java:95) com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175) com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) java.security.AccessController.doPrivileged(Native Method) com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:104) com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:176)
    The files which i am uploading the file from the Best practises only.
    What is the reason for this error?
    Did any one get this error?
    Regards,
    Kumar Rayudu
    Edited by: Kumar Rayudu on Aug 4, 2009 12:32 PM

    Hello Kumar,
    Have you uploaded the SAP text and object files? Upload them first and then try to upload functions.
    Harleen
    SAP GRC RIG

  • Error while activating the function module

    hi,
    am getting error while activating the function module i.e. program or report statement is missing.
    thank you in advance
    karthik

    hii vinu,
    hi there....
    make sure that the Processing type in Attributes tab is 'Normal function module'. Also chk the general data, it must be having some name in the Program Name and include name column.try checking the program names in se38, if the program is of type include or not. you can also chk by writting  a program call the function module and test it
    I hope this will solve the query. in my case, SAPLZ123 is the program name and LZ123U28 is the include name.
    or
    Its common prob with Function module.
    Goto SE80->Give Function group name->Right click on it->Activate.
    regards,
    Shweta

  • Error while executing planning Function

    Hi All,
    I'm getting some error while executing planning function. Below are errors. Please check and provide solution.
    Errors occurred when executing planning function RTFMPF01/RTFMPG01
    Value 08 of chara Region does not correspond to the attrib.val MI of chara Store
    Value 10 of chara Region does not correspond to the attrib.val RM of chara Store
    Value 11 of chara Region does not correspond to the attrib.val NA of chara Store
    Thanks,
    Vamsi

    Hi,
    Value 08 of chara Region does not correspond to the attrib.val MI of chara Store
    Looks like there is a characteristics relationship which derives the attribute store from Region.
    Check the master data for Region for attribute Store and the corresponding values.
    The values that are maintained in the master data will only be allowed to enter in the cube.
    Thanks
    pratyush

Maybe you are looking for