Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to use Module??

ollie991ollie991 Posts: 21Member
why program on Module?
and how to use it?

Comments

  • francisstokesfrancisstokes Posts: 43Member
    [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]


  • ollie991ollie991 Posts: 21Member
    : [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, ??
  • francisstokesfrancisstokes Posts: 43Member
    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.
  • ollie991ollie991 Posts: 21Member
    : 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?
  • francisstokesfrancisstokes Posts: 43Member
    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.
  • ollie991ollie991 Posts: 21Member
    : 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!!!
  • iwilld0itiwilld0it Posts: 1,134Member
    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.