Click here to Skip to main content
15,916,600 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Generalright to left TreeView Pin
sweeeeeeeeeet man27-Feb-05 4:26
susssweeeeeeeeeet man27-Feb-05 4:26 
GeneralRe: right to left TreeView Pin
Dave Kreskowiak28-Feb-05 4:57
mveDave Kreskowiak28-Feb-05 4:57 
GeneralLogin User Pin
Ahmad Rifai Yusuf27-Feb-05 1:40
Ahmad Rifai Yusuf27-Feb-05 1:40 
GeneralRe: Login User Pin
Mohammad Daba'an27-Feb-05 4:23
Mohammad Daba'an27-Feb-05 4:23 
GeneralRe: Login User Pin
Mandar Patankar27-Feb-05 6:17
Mandar Patankar27-Feb-05 6:17 
GeneralRe: Login User Pin
albCode27-Feb-05 6:38
albCode27-Feb-05 6:38 
QuestionHow to write and call a module in VB.net Pin
eshban28426-Feb-05 20:28
eshban28426-Feb-05 20:28 
AnswerRe: How to write and call a module in VB.net Pin
Mitch F.26-Feb-05 20:45
Mitch F.26-Feb-05 20:45 
Hello,

Right click your project and then click on Add->Add Module. Give the module any name.

Create a Function within the module, such as: (in this case, I named my Module "Functions" and my Function "Test()". I used the code you provided just for an example. You can name the Module and the Function differently. Here is the complete module)
VB
Module Functions
    Function test()
        Dim cm As New SqlClient.SqlCommand
        Dim cn As New SqlClient.SqlConnection

        cn.ConnectionString = "data source=abc; initial catalog=books; user id= sa; password=sa;"
        cn.Open()

        cm.Connection = cn
        cm.CommandText = "select * from info"
        cm.CommandType = CommandType.Text
    End Function
End Module


To call the function, all that you need to do is use the function name that you put it under. In my case, I would use test() wherever I needed the code to be executed.

I hope this solves your problem Smile | :) ,

Programmer2k4

My sig:

"The so-called 'Bugs' do not exist, they are merely features hidden by developers with message boxes that say 'An unhandled exception has occurred'." - Programmer2k4

"And it is a professional faux pas to pay someone else to destroy your computer when you are perfectly capable of destroying it yourself." - Roger Wright


I now use my CodeProject Blog!

GeneralRaj Settiappli Pin
shijutheertha26-Feb-05 19:35
shijutheertha26-Feb-05 19:35 
GeneralRe: Raj Settiappli Pin
Dave Kreskowiak28-Feb-05 4:59
mveDave Kreskowiak28-Feb-05 4:59 
GeneralPausing until value change [Updated 2 times] Pin
Mitch F.26-Feb-05 16:34
Mitch F.26-Feb-05 16:34 
GeneralRe: Pausing until value change [Updated 2 times] Pin
Dennis C. Dietrich27-Feb-05 1:45
Dennis C. Dietrich27-Feb-05 1:45 
GeneralRe: Pausing until value change [Updated 2 times] Pin
Mitch F.27-Feb-05 5:10
Mitch F.27-Feb-05 5:10 
GeneralRe: Pausing until value change [Updated 2 times] Pin
H@is@here27-Feb-05 11:44
H@is@here27-Feb-05 11:44 
GeneralWake up from stand by / hibertane Pin
Jackiem300126-Feb-05 12:43
Jackiem300126-Feb-05 12:43 
GeneralRe: Wake up from stand by / hibertane Pin
Colin Angus Mackay26-Feb-05 16:32
Colin Angus Mackay26-Feb-05 16:32 
GeneralRe: Wake up from stand by / hibertane Pin
Jackiem300127-Feb-05 12:59
Jackiem300127-Feb-05 12:59 
GeneralRe: Wake up from stand by / hibertane Pin
Colin Angus Mackay27-Feb-05 13:12
Colin Angus Mackay27-Feb-05 13:12 
GeneralPerfect coders wanted (freelancers) Pin
PavelMenshikov25-Feb-05 23:44
PavelMenshikov25-Feb-05 23:44 
GeneralRe: Perfect coders wanted (freelancers) Pin
Dave Kreskowiak26-Feb-05 4:08
mveDave Kreskowiak26-Feb-05 4:08 
GeneralRe: Perfect coders wanted (freelancers) Pin
Tom John26-Feb-05 4:53
Tom John26-Feb-05 4:53 
GeneralRe: Perfect coders wanted (freelancers) Pin
Dave Kreskowiak26-Feb-05 9:27
mveDave Kreskowiak26-Feb-05 9:27 
GeneralRe: Perfect coders wanted (freelancers) Pin
rwestgraham26-Feb-05 13:43
rwestgraham26-Feb-05 13:43 
GeneralRe: Perfect coders wanted (freelancers) Pin
Dave Kreskowiak26-Feb-05 15:39
mveDave Kreskowiak26-Feb-05 15:39 
GeneralRe: Perfect coders wanted (freelancers) Pin
Colin Angus Mackay26-Feb-05 16:27
Colin Angus Mackay26-Feb-05 16:27 

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.