Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Dot Net (CS/ME-406) : 1. Working With Call Backs and Delegates in Visual Basic

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 7

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 (string.compare(n1,n2)>0)

Return 1;

}
Else if(string.compare(n1,n2)<0)

Return 1;

else

return 0;

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

using system.windows.forms;

public partial class form1: form1

public event Even Handler click;

public form1[ ]

Button btn Hello=New Button[ ];

btnHello.Text=”Hello”;

btnHello.click t=delegate

MessageBox.Show[“Hello”]

Button btnGoodBye=newButton[]

btnGoodBye.Text=”GoodBye”

btnGoodBye.Left=btnHello.width+5

btnGoodBye.click+=delegate[object sender.EventArgs e]

string message=[sender as Button1.text]

MessageBox.show[message];
};

Controls.Add[btnHello];

Controls.Add[btnGoodBye];
3. Using Reflection in Visual Basic.

Using system;

Using system.reflection;

Namespace Reflection Query Test

Public class Test Derived class:TestBaseClass {

Strict TestStruct { }

Interface TestInterface { }

Class Test Attribute:system.Attribute { }

Enum TestEnum { }

Class class1

Private static void Reflect Type(stringsTypeName)

Try

Type type=type.GetType(s TypeName);

Console.WriteLine(“Type name: {0}”,Type.Fullname);

Else

Return 0;

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

Imports system web.mail

Protect sub button1-click

Dim my message as new mail Message

My message.To=”mayank_06@yahoo.in”

My message.From=”mayank_06@yahoo.in”

My message.subject=”This is test”

My message.priority.mail priority.High

My message.Body=”hello from Mayank”

Dim attachment as New Mail attachment(“c:\river sumida.bmp”)

My message.atachment.Add(Attachment)

Smtp mail.send(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”;

str.Replace(“u”,”U”);

console.writeline(str);

console.readline();

}
}

6. Data Sources access from SQL server through ADO.Net

Dim nwindConn As sqlconnection=NewsqlConnection(“Data


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

nwindconn.open()

sqlconnection nwindconn=newsqlconnection

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


catalog=northwind”);

nwindconn.open();

You might also like