Namespace Statement VB.NET

Syntax
Namespace name
component types
End Namespace

name Use: Required Data Type: String literal The name of the namespace component types Use: Required

The elements that are being declared as part of the namespace, including Enums, Structures,Interfaces, Classes, and Delegates

Description Declares a namespace and specifies the items in the namespace

Rules at a Glance

  • Namespaces are used in the .NET Framework as an organized method of exposing program components to other programs and applications.
  • Namespaces are always Public. However, the elements within a namespace can be Public, Friend, or Private. Private members are available only within the namespace declaration. name, the namespace name, must be unique.

Now Property

Class
Microsoft.VisualBasic.DateAndTime

Syntax
Now( )

Return Value
A Date containing the current system date and time

Description
Returns the current date and time based on the system setting

Rules at a Glance

  • The date returned by Now takes the Windows General Date format based on the locale settings of the local computer. The U.S. setting for General Date is mm/dd/yy hh:mm:ss.
  • The Now property is read-only.

Example
The following example returns the date 10 days from today:

MsgBox(DateAdd(DateInterval.Day, 10, Now( )))

Programming Tips and Gotchas

  • It is often overlooked that workstations in a modern Windows environment are at the mercy of the user! If your application relies on an accurate date and time setting, you should consider including a line in the workstation's logon script to synchronize the time with one of the servers. Many so-called bugs have been traced to a workstation that has had its date or time incorrectly altered by the user. The following line of code, when added to the logon script of an Windows NT 4.0 machine, will synchronize the machine's clock with that of a server calledNTSERV1:
    net time \NTSERV1 /set
  • The Now property is often used to generate timestamps. However, for short-term timing and intra-day timestamps, the Timer function, which returns the number of milliseconds elapsed since midnight, affords greater accuracy.
  • The Now property wraps the BCL's System.DateTime.Now shared property. As a result, calls to the System.DateTime.Now property offer a slight performance improvement (about 20%) over calls to the VB .NET Now property.

NPer Function

Class
Microsoft.VisualBasic.Financial

Syntax
NPer(rate, pmt, pv [, fv [, due]])

rate Use: Required Data Type: Double The interest rate per period. Pmt Use: Required Data Type: Double The payment to be made each period. pv Use: Required Data Type: Double The present value of the series of future payments or receipts. fv Use: Optional Data Type: Double

The future value of the series of payments or receipts. If omitted, the default value is 0.

due Use: Optional Data Type: DueDate enumeration

A value indicating when payments are due. DueDate.EndOfPeriod (0) indicates that paymentsare due at the end of the payment period; DueDate.BegOfPeriod (1) that payments are dueat the beginning of the period. If omitted, the default value is 0.

Return Value
A Double indicating the number of payments

Description
Determines the number of payment periods for an annuity based on fixed periodic payments and a fixed interest rate

Rules at a Glance

  • rate is a percentage expressed as a decimal. For example, a monthly interest rate of 1% is expressed as 0.01.
  • For pv and fv, cash paid out is represented by negative numbers; cash received is represented by positive numbers.

Example
Typically, the amount of time required to repay credit-card debt is never explicitly stated. The followingprogram uses the NPer function to determine how much time is required to repay credit-card debt.

Programming Tips and Gotchas

  • Both rate and pmt must be expressed in the same time unit. That is, if pmt reflects the monthly payment amount, rate must be the monthly interest rate.
  • NPer is useful in calculating the number of payment periods required to repay a loan when the monthly loan payment is fixed or when an approximate amount of a monthly payment is known. In this case, pv reflects the amount of the loan, and fv is usually 0, reflecting the fact that the loan is to be entirely repaid.
  • NPer is useful in determining the length of time required to meet some future financial goal. In this case, prepresents the current level of savings, and fv represents the desired level of savings.

NPV Function

Class
Microsoft.VisualBasic.Financial

Syntax
NPV(rate, valuearray( ) )

rate Use: Required Data Type: Double The discount rate over the period, expressed as a decimal valuearray( ) Use: Required Data Type: Double An array of cash flow values

Return Value
A Double specifying the net present value

Description
Calculates the net present value of an investment based on a series of periodic variable cash flows (payments and receipts) and a discount rate.The net present value is the value today of a series of future cash flows discounted at some rate back to the first day of the investment period.

Rules at a Glance

  • rate must be a percentage expressed as a decimal. For example, 10% is expressed as 0.10.
  • values is a one-dimensional array that must contain at least one negative value (a payment) and one positive value (a receipt).
  • The NPV investment begins one period before the date of the first cash flow value and ends with the last cash flow value in the array.
  • NPV requires future cash flows. If the first cash flow occurs at the beginning of the first period, the first value must be added to the value returned by NPV and must not be included in values.

Programming Tips and Gotchas

  • rate and the individual elements of values must reflect the same time period. For example, if values reflects annual cash flows, rate must be the annual discount rate.
  • Individual members of values are interpreted sequentially. That is, values(0) is the first cash flow, values(1) is the second, etc.
  • NPV is like the PV function, except that PV allows cash flows to begin either at the beginning or the end of a period and requires that cash flows be fixed throughout the investment.


Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

VB.NET Topics