0% found this document useful (0 votes)
11 views7 pages

Visual Basic Programming Techniques

The document discusses various topics in Visual Basic .NET including working with callbacks and delegates, creating Windows services, using reflection, sending email with SMTP, performing string manipulation with StringBuilder and String classes, and accessing SQL Server data sources through ADO.NET. Specifically, it provides code examples for comparing names as objects, adding event handlers for buttons, reflecting on types, sending an email with an attachment, replacing characters in a string, and opening a connection to a SQL database.

Uploaded by

badholiya
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views7 pages

Visual Basic Programming Techniques

The document discusses various topics in Visual Basic .NET including working with callbacks and delegates, creating Windows services, using reflection, sending email with SMTP, performing string manipulation with StringBuilder and String classes, and accessing SQL Server data sources through ADO.NET. Specifically, it provides code examples for comparing names as objects, adding event handlers for buttons, reflecting on types, sending an email with an attachment, replacing characters in a string, and opening a connection to a SQL database.

Uploaded by

badholiya
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Dot Net(CS/ME-406)

1. Working with call backs and delegates in Visual Basic.


public delegate int comparer (object obj1,object obj2)

public class Name

Public string first Name=Null;

Public string last Name=Null;

Public Name (string first, string last)

First Name=first;

Last Name=last;

Public static int compare first Name(object name1, object name2)

String n1=((name)name1).first Name;

String n2=((name)name2).first Name;

If ([Link](n1,n2)>0)

Return 1;

}
Else if([Link](n1,n2)<0)

Return 1;

else

return 0;

} }
2. Creating a Windows Service with Visual Basic.
using system;

using [Link];

public partial class form1: form1

public event Even Handler click;

public form1[ ]

Button btn Hello=New Button[ ];

[Link]=”Hello”;

[Link] t=delegate

[Link][“Hello”]

Button btnGoodBye=newButton[]

[Link]=”GoodBye”

[Link]=[Link]+5

[Link]+=delegate[object [Link] e]

string message=[sender as [Link]]

[Link][message];
};

[Link][btnHello];

[Link][btnGoodBye];
3. Using Reflection in Visual Basic.

Using system;

Using [Link];

Namespace Reflection Query Test

Public class Test Derived class:TestBaseClass {

Strict TestStruct { }

Interface TestInterface { }

Class Test Attribute:[Link] { }

Enum TestEnum { }

Class class1

Private static void Reflect Type(stringsTypeName)

Try

Type type=[Link](s TypeName);

[Link](“Type name: {0}”,[Link]);

Else

Return 0;

}
4. Sending Mail and SMTP Mail and Visual Basic.

Imports system [Link]

Protect sub button1-click

Dim my message as new mail Message

My [Link]=”mayank_06@[Link]”

My [Link]=”mayank_06@[Link]”

My [Link]=”This is test”

My [Link] [Link]

My [Link]=”hello from Mayank”

Dim attachment as New Mail attachment(“c:\river [Link]”)

My [Link](Attachment)

Smtp [Link](MyMessage)

5. Perform String Manipulation with the String Builder and String Classes
and Visual Basic

using system;

namespace consoleApplication1 {

class program {

static void main(string{} args) {

string str=”Mouser”;

[Link](“u”,”U”);

[Link](str);

[Link]();

}
}

6. Data Sources access from SQL server through [Link]

Dim nwindConn As sqlconnection=NewsqlConnection(“Data


Source=localhost;Integrated security=SSPI;” &
_+InitialCatalog=northwind”)

[Link]()

sqlconnection nwindconn=newsqlconnection

(“Data source=localhost;Integrated Security=SSPI;”+”Initial


catalog=northwind”);

[Link]();

You might also like