How to use Module??

why program on Module?
and how to use it?

Comments

  • [b][red]This message was edited by francisstokes at 2006-3-18 14:2:56[/red][/b][hr]
    a module is a compiled into a non-graphical appilication. try compiling and running this to see what i mean:

    [code]

    module module1

    sub main()
    console.writeline("Hi there. This basicaly working the same way")
    console.writeline("put a number into a variable...")
    dim var as double
    try
    var = console.readline()
    console.writeline("Your variable was " & var)
    console.readline()
    catch ex as exception
    console.writeline("Error")
    console.readline()
    end try
    end sub
    end module
    [/code]


  • : [b][red]This message was edited by francisstokes at 2006-3-18 14:2:56[/red][/b][hr]
    : a module is a compiled into a non-graphical appilication. try compiling and running this to see what i mean:
    :
    : [code]
    :
    : module module1
    :
    : sub main()
    : console.writeline("Hi there. This basicaly working the same way")
    : console.writeline("put a number into a variable...")
    : dim var as double
    : try
    : var = console.readline()
    : console.writeline("Your variable was " & var)
    : console.readline()
    : catch ex as exception
    : console.writeline("Error")
    : console.readline()
    : end try
    : end sub
    : end module
    : [/code]
    :
    :
    :


    I tried this, but it doesn't do any thing.
    it just compiled and stop, nothing happens, ??
  • It should work. Ok, try making a new project, and selecting console application. Then paste my code over what is there and then run it.
  • : It should work. Ok, try making a new project, and selecting console application. Then paste my code over what is there and then run it.
    :


    oh, yeah, got it. but what is the purpose of using a module?
    why use it?
  • well, you might want to write an application that doesnt need a big user interface. you can write smaller apps, and you can use your code over and over (which you can do anyway).
    sometimes it makes more sense to write a console app. i mean, you could write a progarm that ran in the background, and wrote to a text file every ten minutes. that wouldn't need a user interface and wouldnt take up much memmory.
  • : well, you might want to write an application that doesnt need a big user interface. you can write smaller apps, and you can use your code over and over (which you can do anyway).
    : sometimes it makes more sense to write a console app. i mean, you could write a progarm that ran in the background, and wrote to a text file every ten minutes. that wouldn't need a user interface and wouldnt take up much memmory.
    :

    I understand, thank you very much!!!
  • Module is just a place to organize functions ... as far the .NET Framework is concerned, a module is really converted to a sealed class behind the scenes w/ static functions.

    This is ...

    [code]
    Public Module MyModule

    Sub New()
    ' Initialize
    End Sub

    Public Function DoSomething() As Boolean
    ' Do something
    End Function

    End Module
    [/code]

    ... the same as ...

    [code]
    Public [b]NotInheritable[/b] Class MyModule
    Private Sub New()
    ' Make sure user can not instantiate.
    End Sub

    Shared Sub New
    ' Initialize
    End Sub

    Public [b]Shared[/b] Function DoSomething() As Boolean
    ' Do something
    End Function

    End Class
    [/code]

    I guess you can say a Module is a coding shortcut, but for Visual Basic ONLY.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories