Click here to Skip to main content
16,005,826 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Asynchronus Reading Pin
Dave Kreskowiak3-Mar-08 9:23
mveDave Kreskowiak3-Mar-08 9:23 
GeneralChild Forms Names Pin
Senthil S2-Mar-08 23:36
Senthil S2-Mar-08 23:36 
GeneralRe: Child Forms Names Pin
Anoop Brijmohun3-Mar-08 0:22
Anoop Brijmohun3-Mar-08 0:22 
GeneralRe: Child Forms Names Pin
Dave Kreskowiak3-Mar-08 4:30
mveDave Kreskowiak3-Mar-08 4:30 
GeneralRe: Child Forms Names Pin
Anoop Brijmohun3-Mar-08 6:43
Anoop Brijmohun3-Mar-08 6:43 
GeneralRe: Child Forms Names Pin
Dave Kreskowiak3-Mar-08 7:23
mveDave Kreskowiak3-Mar-08 7:23 
GeneralRe: Child Forms Names Pin
Anoop Brijmohun3-Mar-08 19:28
Anoop Brijmohun3-Mar-08 19:28 
Generalprogram not working...need somehelp Pin
Danisto2-Mar-08 22:56
Danisto2-Mar-08 22:56 
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
GeneralRe: program not working...need somehelp Pin
Dave Kreskowiak3-Mar-08 9:16
mveDave Kreskowiak3-Mar-08 9:16 
GeneralRe: program not working...need somehelp Pin
Steve Erbach4-Mar-08 4:08
Steve Erbach4-Mar-08 4:08 
GeneralAccessing a datagrid item inside a datagrid nested in a datagrid. Pin
DoctorStrop2-Mar-08 22:08
DoctorStrop2-Mar-08 22:08 
GeneralAccess Problem - VB Application Pin
aaraaayen2-Mar-08 21:03
aaraaayen2-Mar-08 21:03 
GeneralRe: Access Problem - VB Application Pin
Vimalsoft(Pty) Ltd2-Mar-08 21:59
professionalVimalsoft(Pty) Ltd2-Mar-08 21:59 
GeneralRe: Access Problem - VB Application Pin
aaraaayen2-Mar-08 23:00
aaraaayen2-Mar-08 23:00 
GeneralRe: Access Problem - VB Application Pin
Anoop Brijmohun2-Mar-08 23:05
Anoop Brijmohun2-Mar-08 23:05 
GeneralRe: Access Problem - VB Application Pin
aaraaayen2-Mar-08 23:49
aaraaayen2-Mar-08 23:49 
GeneralRe: Access Problem - VB Application Pin
Anoop Brijmohun3-Mar-08 0:15
Anoop Brijmohun3-Mar-08 0:15 
GeneralRe: Access Problem - VB Application Pin
aaraaayen3-Mar-08 1:03
aaraaayen3-Mar-08 1:03 
GeneralRe: Access Problem - VB Application Pin
Anoop Brijmohun3-Mar-08 1:31
Anoop Brijmohun3-Mar-08 1:31 
GeneralFastest way to pull data out of MS Access DB Pin
Jan Sommer2-Mar-08 20:48
Jan Sommer2-Mar-08 20:48 
GeneralRe: Fastest way to pull data out of MS Access DB Pin
Christian Graus2-Mar-08 22:38
protectorChristian Graus2-Mar-08 22:38 
GeneralRe: Fastest way to pull data out of MS Access DB Pin
Jan Sommer2-Mar-08 23:34
Jan Sommer2-Mar-08 23:34 
GeneralRe: Fastest way to pull data out of MS Access DB Pin
Dave Kreskowiak3-Mar-08 4:29
mveDave Kreskowiak3-Mar-08 4:29 
GeneralRe: Fastest way to pull data out of MS Access DB Pin
Jan Sommer3-Mar-08 21:11
Jan Sommer3-Mar-08 21:11 
GeneralRe: Fastest way to pull data out of MS Access DB Pin
Dave Kreskowiak4-Mar-08 1:34
mveDave Kreskowiak4-Mar-08 1:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.