|
thanks, appreciate your help!
|
|
|
|
|
A quick explanation of what I am trying to achieve: for each bond that is selling in the stock market, there will be an issue date, maturity date, frequency of interest payments and lastly the interest rate. What I want is to have a function that allows me to input a date any time before the bond matures, and give me as an output a series of outstanding cashflows and the corresponding dates.
Explanation of the variables in the code
Valdate = todays date
Ipos = indicator +1 or -1 depending if I have bought or borrowed the bond
Notional = amount of bond
D1 = date of bond issue
D2 = date of maturity
Freq = frequency of interest payments
Coupon = interest rate
V() = vector of all cashflow dates for the bond
Cashflow = 2 by p matrix of the bond (dates and corresponding amounts)
Code:
Function bondcashflow(valdate, ipos, notional, d1, d2, freq, coupon)
Dim p, m As Integer
Dim v()
Dim cashflow()
ReDim cashflow(2, p) As Variant
Dim n As Long
n = Application.Round(DateDiff("d", d1, d2) / 365 * freq, 0)
For i = 0 To n - 1
If freq = 1 Then
v(i) = DateAdd("yyyy", 1 * i, d1)
ElseIf freq = 2 Then
v(i) = DateAdd("q", 2 * i, d1)
ElseIf freq = 4 Then
v(i) = DateAdd("q", 1 * i, d1)
ElseIf freq = 12 Then
v(i) = DateAdd("m", 1 * i, d1)
End If
m = 0
If valdate < v(i) Then
m = m + 1
End If
Next i
p = n - m
For k = 1 To p
cashflow(1, k) = v(k + m - 1)
Do While k < p
cashflow(2, k) = ipos * coupon * notional
Loop
Next k
cashflow(2, p) = ipos * (notional + coupon * notional)
bondcashflow = cashflow
End Function
|
|
|
|
|
Danisto wrote: What I want is to have a function that allows me to input a date any time before the bond matures, and give me as an output a series of outstanding cashflows and the corresponding dates.
OK. So what's the problem?
|
|
|
|
|
Danisto,
Just a brief glance through your code shows that in the For loop at the end you've embedded "Do While k < p". The loop has no exit; that is, it's an infinite loop.
Also, the ReDim of the cashflow array uses p as the second dimension, but p hasn't been assigned a value at that point.
Is your Code block really supposed to be pseudo-code?
Regards,
Steve Erbach
Neenah, WI
|
|
|
|
|
Hi,
I have a nested datagrid which has drop down lists inside it. Which are populated as follows...
Private Sub loadSystemsTables(ByRef dg As DataGrid)
'loads the dropdownlists for the editors
Dim db As New database
Dim SystemDS As DataSet
Dim evtHandle As New DataGridItemEventHandler(AddressOf childItemDataBound)
Dim SystemsSQL As String
If Not dg Is Nothing Then
'we have a DataGrid
SystemsSQL = "SELECT * FROM tblSystems"
SystemDS = db.db_getDataSet(SystemsSQL)
AddHandler dg.ItemDataBound, evtHandle
dg.DataSource = SystemDS
dg.DataBind()
Else
MessageLabel.Text = "Couldnt find DataGrid"
MessageLabel.UpdateAfterCallBack = True
End If
End Sub
Public Sub childItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
'Dim sysID as integer
'Dim lbl As Label
'lbl = e.Item.FindControl("SystemsIDLabel")
'If Not lbl Is Nothing Then
' sysID = lbl.Text
'End If
Dim ddl As Anthem.DropDownList
ddl = e.Item.FindControl("RoleDropDown")
If Not ddl Is Nothing Then
loadRoleEditors(sysID, ddl)
End If
End Sub
Inside the inner datagrid I have the following items...
<anthem:label runat="server" id="SystemIDLabel">]]>
<anthem:dropdownlist runat="server" id="RoleDropDown" cssclass="DDLSize5">
What I need to know is how to get the value of the "SystemIDLabel" label so I can pass it to the loadRoleEditors sub as I need to set the drop down lists to previously selected values. The value is displayed when the code is run, but if I uncomment the section in sub childItemDataBound() then I get Null. What I think is happening is the sub is running before the value is inserted into the datagrid.
Anyone know how to get this, or is there another way.
Cheers
Andy
|
|
|
|
|
Hi Friends,
I am developing on vb application in my local system.
this application should be used by others users in my team to enter their ot details and everything.
In that application throughout i am using the connection string as
Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\sanramal\sanramal1\overtime log\Overtime Log\Data\OT_Log.mdb"
This application permanently installed in local system and the system name is sanramal.
The mdb file is presented in sanramal1\overtime log\overtime log\data\ot_log.mdb
so in the connection string i have given my system name followed by the shared folder which includes the mdb file.
I have done with Package and Development Wizard.
i install this in other desktop.
But when i started working (test) in that desktop, it has given error
"cannot access \\sanramal\sanramal1\overtime log\Overtime Log\Data\OT_Log.mdb - its exclusively opened by other user...."
Please help me to resolve this problem.
Its very very urgent.
Thanks in Advance,
|
|
|
|
|
hi man
let me ask you few Questions to understand your Question.
Where is the MDB File, is it localy on your Machine?
If its a share, does your Users have access to it and Permissions?
Are your Users Connected to the network? (want to make sure)
aaraaayen your Error is simple to solve, it simply means your application cant find the DB, you need to make the correct mapping to your DB,
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hi Vuyiswa,
Thanks lot.
Yes mdb file is located in my machine.
It is shared in a folder...But i dont know really about the permission...
Users are connected to the network....
Error I am receiving:
Microsoft jet databse engine cannot open the file (path). It is already opened exclusively by another user, or you need permission to view its data...
Please help me.
Expecting your favourable reply.
Regards,
|
|
|
|
|
Hi,
i experienced the similar problem once...
it happened when the program tries to read a table that is opened by a user.
try to close all tables and run the app.
|
|
|
|
|
Yes...but i closed the mdb file b4 opening the application..
what kind of permission i have to give for that file?
Thanks lot for your reply.
Regards,
|
|
|
|
|
mmmm..
permission set as normal, you can try to add 'everyone' with read and write....
here are 2 other suggestions...
1. maybe someon else has this file open. check for the '.ldb' file in that directory then you wil know.
2. why not create an odbc connection under admin tools to this mdb file.
then in you code you can call up this datasource eg.i have always used this and it hasn't given me any errors thus far....
here is the connectionstring = "DSN=TEST;PWD=PASSWORD"
where 'TEST' is the datasource name and password if any password!
sorry but this all i can think of at this moment, will check on other solutions.
|
|
|
|
|
Thanks lot.
Yes But I am having one doubt with DSN.
When i create and use with(System DSN)...then i need to create dsn in all the systems? or is there any options in Package and Deployment, that will automatically create dsn in all the systems when we install this application?
Expecting your reply.
Regards,
|
|
|
|
|
Yes, there is a way,
have not tried it myself but you can give it a shot...
here is what you do...
if not create the access odbc connection to the mdb file...then
[A.] Familiarise yourself with this...
1. click start..run- type in regedit.
2. navigate to HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\[your datsource name]
3. you will notice that there are certain folders and files taht point to the file along with Engines!
[B.] NEXT...
1. open you project, right click your setup project name and select "View Registry"
2. You now have a registry tree in front of you.
3. you will need to re-create the treenodes here as found in the registry editor mentioned above in [A].
4. build and install on your pc to test!
this should create the odbc with relevant info....
hope this helps...
|
|
|
|
|
Currently i'm pulling out data by using this code:
odCommand = New OleDbCommand("select top 5000 * from TPers, TComp where tpers.compkey = tcomp.compkey", odConnection)
odReader = odCommand.ExecuteReader
While odReader.Read
InsertDBIndexData(odReader("persid").ToString, odReader("cpr").ToString, odReader("firstname").ToString & " " & odReader("lastname").ToString, odReader("legalname").ToString, odReader("tpers.address1").ToString)
End While
odReader.Close()
this takes 5 minutes and 5000 people is indexed in my LuceneDB. But the AccessDB contains more than 100.000 people, so the faster the better. I also tried to index the whole DB, but with this code it's never finished. Don't know why.
What's the fastest and best way to pull data from an AccessDB?
|
|
|
|
|
I doubt Access is as fast as SQL Server, perhaps you've outgrown access ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I'm afraid i have no choice but to stick with Access. But you're certainly right though.
There's no way to get that data any faster than using the method i've already posted? Or just a better method that wont crash the program if it's running for too long.
|
|
|
|
|
Not really. Why are you using the TOP modifier in the SQL? You're not doing any ordering, so it looks like you're just using it to limit the results returned, which could be ANY 5000 of the record set returned constrained by the WHERE clause.
The biggest part of the problem may not be the records returned, but by the code running in InsertDBIndexData . If it's adding data to a sorted collection, the data will be added slower and slower as the size of the collection increases.
|
|
|
|
|
Thanks for your reply.
I'm not sorting anything, only adding it to a Lucene.Net indexing database. This is how the code looks:
Private Sub InsertDBIndexData(ByVal idbID As Integer, ByVal sCPR As String, ByVal sName As String, ByVal sCompany As String, ByVal sAddress As String, ByVal sStatus As String, ByVal sType As String)
'New person in the index
Dim writer As New Lucene.Net.Index.IndexWriter(DBIndexLocation, New StandardAnalyzer, False)
Dim doc As New Document
Dim f1 As New Field("dbID", idbID, Field.Store.YES, Field.Index.NO)
Dim f2 As New Field("CPR", sCPR, Field.Store.YES, Field.Index.TOKENIZED)
Dim f3 As New Field("Name", sName, Field.Store.YES, Field.Index.TOKENIZED)
Dim f4 As New Field("Company", sCompany, Field.Store.YES, Field.Index.TOKENIZED)
Dim f5 As New Field("Address", sAddress, Field.Store.YES, Field.Index.TOKENIZED)
Dim f6 As New Field("Status", sStatus, Field.Store.YES, Field.Index.NO)
Dim f7 As New Field("Type", sType, Field.Store.YES, Field.Index.NO)
doc.Add(f1)
doc.Add(f2)
doc.Add(f3)
doc.Add(f4)
doc.Add(f5)
doc.Add(f6)
doc.Add(f7)
writer.AddDocument(doc)
writer.Optimize()
writer.Close()
End Sub
Private Sub newIndex()
Dim odConnection As oleDbConnection = new oleDbConnection("......db.mdb")
odConnection.Open()
Dim writer As New Lucene.Net.Index.IndexWriter(DBIndexLocation, New StandardAnalyzer, True)
writer.Close()
odCommand = New OleDbCommand("select * from Customers", odConnection)
odReader = odCommand.ExecuteReader
While odReader.Read
'InsertDBIndexData(odReader("id"), odReader("cpr"), odReader("firstname") & " " & odReader("lastname"), odReader("legalname"))
InsertDBIndexData(odReader("persid").ToString, odReader("cpr").ToString, odReader("firstname").ToString & " " & odReader("lastname").ToString, odReader("legalname").ToString, odReader("address1").ToString, odReader("Status").ToString, odReader("InsType").ToString)
End While
odReader.Close()
End Sub
The only optimizing i can figure out here, is to only open the (Lucene.Net)writer once. And when i'm indexing it also takes up ALOT of resources. Is there any way i can limit that?
Would it be better to first drag everything out of the DB, place it in an ArrayList and when that's done, start moving it to the Lucene.Net index?
|
|
|
|
|
Jan Sommer wrote: writer.AddDocument(doc) writer.Optimize()
I get the feeling that this is where your code spends most of it's time. Just on these two lines. You can use the ANTS profiler, or CompuWare's, to find out how much time it takes to execute these instructions.
Jan Sommer wrote: And when i'm indexing it also takes up ALOT of resources. Is there any way i can limit that?
No, there isn't.
|
|
|
|
|
The writer.optimize() part certainly took alot of time. I removed it and placed it after the while odreader.read, and that saved me 1/3 of the time it took to index the db. But it still isn't fast enough.
Currently i'm indexing the DB and when i check the taskmanager it says something like:
Process: IndexService.exe, CPU: 00 (sometimes 01) and memory: between 100.000 and 800.000
Why is it taking up all the memory and not using the CPU?
The indexing program is soon going to run on a server with a bit more ram. I hope that will speed up things a little.
Will it be any faster if i somehow convinced the IT-department to switch to MSSQL?
|
|
|
|
|
We have a problem with outlook size limit and are not allowed to create pst. I can only copy those msg to a folder. Do you have any idea how to store this msg in access and create forms in access to view this msg.
|
|
|
|
|
Can I select a certain time such as 4:00PM on a particular date with a dateTime picker?
I only saw a date selection in the dateTime picker.
|
|
|
|
|
hi,
use following code to getTime.
MsgBox(DateTimePicker1.Value.TimeOfDay.ToString)
also if you want to display time with date in datetimepicker then change the "format" property of datetimepicker to "Custom" and custom property to MM/dd/yyyy hh mm tt
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
Can I make it so that the time picker will only choose each hour or half hour.
|
|
|
|
|
hi,
i does not properly get you (Because of my poor english). Please told your problem in detail & simple way, so i can suggest you.
However you can show only time in DatetimePicker by change the CustomFormat property to "hh mm tt"
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|