Wednesday, June 25, 2008

OOPs in VB.Net

0. VB.Net don't support : Operator Overloading, Multiple Inheritance

1. Private interfaces can not be implemented (Ans)
Explanation: Interfaces must always be declared as public so that they can be
implemented or inherited
2. a subclass created
With the help of Inherits.
3. encapsulation :Hiding the implementation and exposing the interface and is The
separation of interface and implementation
4. interface implementation requires Implements keyword for to be implemented.
5. Static Methods can't be overridable
6. significance of Shadowing :It replaces all the implementation from high in the
inheritance chain.
7. In VB.Net Abstract class is specified with MustInherit keyword.
8. Polymorphism is implemented using Method Overloading,Method Overriding
9. overloading operators requires Overloads keyword.
10. encapsulation : The separation of interface and implementation.
11. Late Binding, Multiple Interfaces and . NET Reflection can be used to achieve
polymorphic behavior of an object.

Sunday, June 22, 2008

Tips

You can access the Application information easily as can be seen in the following lines of code

My.Application.AssemblyInfo.DirectoryPath
My.Application.AssemblyInfo.ProductName
My.Application.Log.WriteEntry(“Application Starting”, EventLogEntryType.Information, Nothing)

The above lines of code will retrieve this information from the assembly which can used by the application on run time.


properties and methods of the My.Application Object

ApplicationContext Gives access to the context associated with the current thread.

AssmblyInfo Allows easy access to data from the AssemblyInfo.vb file, including CompanyName, ProductName, Title and Version.

ChangeCurrentCulture Allows Change the culture in which the current thread is running, which affects such things as string manipulation and formatting

ChangeCurrentUICulture Allows changing the culture that the current thread uses for retrieving culture-specific resources

CommandLineArgs Return a collection of command-line arguments

CurrentCulture Returns a collection of command-line arguments

CurrentDirectory Returns the folder where the application resides

CurrentUICulture Returns the culture that the current thread is using for retrieving culture-specific resources

DoEvents Causes all messages in the message queue to be processed

GetEnvironmentVariable Returns a specific environment variable on the local maching\e

IsNetWorkDeployed Returns True if the application was network-deployed else returns False.

Log Allows writing to application log on the local machine

MainForm A read-write property that allows setting or getting the form that the application will use as its main form

Run Sets up and starts the VB Startup/Shutdown Application model

SplashScreen Lets setting or getting the application's splash screen

Visual Basic has a public function MsgBox. It displays a message in a dialog box, waits for the user to click a button, and then returns an integer indicating which button the user clicked.

Public Function MsgBox( _
ByVal Prompt As Object, _
Optional ByVal Buttons As MsgBoxStyle = MsgBoxStyle.OKOnly, _
Optional ByVal Title As Object = Nothing _
) As MsgBoxResult

The MsgBoxStyle enumeration values are listed in the following table.

Enumeration

Value

Description

OKOnly

0

Displays OK button only.

OKCancel

1

Displays OK and Cancel buttons.

AbortRetryIgnore

2

Displays Abort, Retry, and Ignore buttons.

YesNoCancel

3

Displays Yes, No, and Cancel buttons.

YesNo

4

Displays Yes and No buttons.

RetryCancel

5

Displays Retry and Cancel buttons.

Critical

16

Displays Critical Message icon.

Question

32

Displays Warning Query icon.

Exclamation

48

Displays Warning Message icon.

Information

64

Displays Information Message icon.

DefaultButton1

0

First button is default.

DefaultButton2

256

Second button is default.

DefaultButton3

512

Third button is default.

ApplicationModal

0

Application is modal. The user must respond to the message box before continuing work in the current application.

SystemModal

4096

system is modal. All applications are suspended until the user responds to the message box.

MsgBoxSetForeground

65536

Specifies the message box window as the foreground window.

MsgBoxRight

524288

Text is right-aligned.

MsgBoxRtlReading

1048576

Specifies text should appear as right-to-left reading on Hebrew and Arabic systems.



The VB.Net framework graphically can be viewed as below:


The brief description of the various features of the dot net framework is can be considered as below:


  • An object oriented programming model (inheritance, polymorphism, exception handling etc);
  • A common standardised type system;
  • Metadata support for all types at run-time;
  • A comprehensive set of .NET Framework classes that encapsulate most of the Win32 API and several other technologies, such as data access and XML parsing;
  • Advanced debugging and profiling support;
  • 'Virtualised' code execution and memory management;
  • A system-wide garbage collector handling the object lifetime of all managed memory;
  • Intermediate Language to native code translators;
  • A declarative security model.