473,387 Members | 1,455 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Error in calculating irr in asp.net and vb.net

i am calculating irr and pass listarray created at runtime to irr function and i get error. as i'm new to .net
i have to calculate irr
textbox2.text specify the no installments
textbox1.text specify loan amount
textbox5.text specify the amount of installments
Dim i As Int16
Dim pay As New ArrayList()
For i = 0 To TextBox2.Text
pay.Add(TextBox5.Text)
Next
pay.Add(-TextBox1.Text)
Dim ir As Double
ir = Math.Round(Microsoft.VisualBasic.Financial.IRR(pay (TextBox2.Text + 1), 0.1), 2)
TextBox7.Text = ir
GET THIS ERROR MESSAGE
Unable to cast object of type 'System.Double' to type 'System.Double[]'.
Sep 10 '08 #1
10 3797
shweta123
692 Expert 512MB
Hi,

I think there is type mismatch in parameter types while calling the following function :

ir = Math.Round(Microsoft.VisualBasic.Financial.IRR(pay (TextBox2.Text + 1), 0.1), 2).

This is because the type of parameters in the function definition IRR must match the type of parameters passed to the function.
Please check the return type and parameter type of function IRR in order to remove the error you are getting.
Sep 10 '08 #2
thanks shweta123

I think there is type mismatch in parameter types while calling the following function :

ir = Math.Round(Microsoft.VisualBasic.Financial.IRR(pay (TextBox2.Text + 1), 0.1), 2).

as i am passing arraylist (pay(15) as ist parameter and guess (0.1) as 2nd
parameter the variable ir is taken as double
as irr function will only return the value of irr which would be double
Sep 12 '08 #3
shweta123
692 Expert 512MB
Hi,

Following is the method for solving the error you are getting :

1> Please see the function definition and check the parameters your function is accepting.
2> Call the function with same types of parameters.
3> If you are sending different types of parameters to the function then
you can call the function by doing typecasting method.

thanks shweta123

I think there is type mismatch in parameter types while calling the following function :

ir = Math.Round(Microsoft.VisualBasic.Financial.IRR(pay (TextBox2.Text + 1), 0.1), 2).

as i am passing arraylist (pay(15) as ist parameter and guess (0.1) as 2nd
parameter the variable ir is taken as double
as irr function will only return the value of irr which would be double
Sep 13 '08 #4
Hi,

Following is the method for solving the error you are getting :

1> Please see the function definition and check the parameters your function is accepting.
2> Call the function with same types of parameters.
3> If you are sending different types of parameters to the function then
you can call the function by doing typecasting method.
hi shweta
irr function returns value of irr which is of type double and the double variable is used to hold the value
Sep 15 '08 #5
PRR
750 Expert 512MB
First and foremost you should use conversion of string for surety that your inputs are right....
Convert.ToInt() or Convert.ToDouble();

Expand|Select|Wrap|Line Numbers
  1.  
  2. int i;
  3.             ArrayList pay =new ArrayList();
  4.             // Better Option is 
  5.             List<int> pay1=new List<int>();
  6.  
  7. //For i = 0 To TextBox2.Text?? 
  8.             // What exactly are you doin here?
  9.             //for(int 0;i<Convert.ToInt32(TextBox.Text);i++)//
  10.  
  11. ir = //YOURFUNCTION(pay[index],0.1,2);
  12. //(pay (TextBox2.Text + 1), 0.1), 2)
  13. // what exactly are you passing in the function?
  14.  
  15.  
Sep 15 '08 #6
thanx dirtbag

I am developing application for loan purposes and i have to calculate irr
textbox2.text specify the no installments
those no equal installments are added to arraylist
Expand|Select|Wrap|Line Numbers
  1. //For i = 0 To TextBox2.Text?? 
  2.             // Add elements of array list
  3.             //for(int 0;i<Convert.ToInt32(TextBox.Text);i++)//
  4.  
  5. ir = //YOURFUNCTION(pay[index],0.1,2);
  6. //(pay (TextBox2.Text + 1), 0.1), 2)
  7. // what exactly are you passing in the function?
  8.  
passing arraylist (pay(x) as ist parameter and guess (0.1)
as i have also mentioned whole problem in my posts
thanks again for response
Sep 17 '08 #7
PRR
750 Expert 512MB
thanx dirtbag

I am developing application for loan purposes and i have to calculate irr
textbox2.text specify the no installments
those no equal installments are added to arraylist
<code>
//For i = 0 To TextBox2.Text??
// Add elements of array list
//for(int 0;i<Convert.ToInt32(TextBox.Text);i++)//

ir = //YOURFUNCTION(pay[index],0.1,2);
//(pay (TextBox2.Text + 1), 0.1), 2)
// what exactly are you passing in the function?
</code>

passing arraylist (pay(x) as ist parameter and guess (0.1)
as i have also mentioned whole problem in my posts
thanks again for response
where exactly have you got d prob? post some code n error message...
Sep 17 '08 #8
hi dirtbag
'code Starts
Dim i As Int16
Dim pay As New ArrayList()
For i = 0 To TextBox2.Text
pay.Add(TextBox5.Text)
Next
pay.Add(-TextBox1.Text)
Dim ir As Double
ir = Math.Round(Microsoft.VisualBasic.Financial.IRR(pay (TextBox2.Text + 1), 0.1), 2)
TextBox7.Text = ir
'code Ends

GETTTING THIS ERROR MESSAGE
Unable to cast object of type 'System.Double' to type 'System.Double[]'.
Sep 18 '08 #9
PRR
750 Expert 512MB
hi dirtbag
'code Starts
Dim i As Int16
Dim pay As New ArrayList()
For i = 0 To TextBox2.Text
pay.Add(TextBox5.Text)
Next
pay.Add(-TextBox1.Text)
Dim ir As Double
ir = Math.Round(Microsoft.VisualBasic.Financial.IRR(pay (TextBox2.Text + 1), 0.1), 2)
TextBox7.Text = ir
'code Ends

GETTTING THIS ERROR MESSAGE
Unable to cast object of type 'System.Double' to type 'System.Double[]'.
As far as i can see your function returns Double[] ; so declare double array ..
Dim ir as Double[]; or in C#
double[] ir;
Sep 18 '08 #10
could any body has solved my problem as i am not getting the solution yet
Sep 22 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ron Adam | last post by:
Hi, I'm having fun learning Python and want to say thanks to everyone here for a great programming language. Below is my first Python program (not my first program) and I'd apreciate any...
0
by: Kasp | last post by:
Hi there, I am trying to make an OLAP cube on a table having two columns (datetime, Number_of_times_an_event_occured). My dimension is time and I want to measure the Min and Max times an event...
17
by: Adam | last post by:
Hi! I've modified a javascript order form calculation script that tallies up the subtotal, shipping/handling, and total automatically. I did some modifications and it still worked fine, even...
1
by: Joe Bongiardina | last post by:
What does the message "calculating...." mean in the lower left status area of a form? I have a form with no calculated, concatenated or lookup fields, yet it displays this msg. The form takes...
1
by: jlm | last post by:
I have a form which feeds table (TblEmpLeave) of Employee Leave Time (time taken off for Administrative, Annual, Sick, Compensation leave). I have EmpID, LeaveDate, LeaveType, LeaveHours fields on...
10
by: Chris Baxter | last post by:
In my program I am trying to do a simple calculation of 5.1 * 100 which should =510 if my gradeschool level math is correct. My problem is vb.net is returning 509.99999999999994 as the answer. Am...
1
by: whitehorse | last post by:
When the warehousecontroller service is invoked, the following error message is sent to the application log: Event Type: Error Event Source: TFS Warehouse Event Category: None Event ID: 3000...
10
by: Lisa | last post by:
In translating the formula for calculating lottery odds for various conditions into a Visual Basic Program, I have apparently missed something in that I get errors in the part of the calculation...
4
by: sumit kale | last post by:
Hi, Can somebody help me resolve my problem ? I am getting error when calculating total using unbound textfiled in subform. I have a main form called purchase_register_master and a subform...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.