Brief Description of Module in VB

How to use module & class module in vb

Page 1 of 1

2 Replies - 2108 Views - Last Post: 19 January 2010 - 07:07 AM Rate Topic: -----

#1 joydipdas  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-January 10

Brief Description of Module in VB

Post icon  Posted 18 January 2010 - 11:15 PM

Please describe me how to use module in vb????
including all kind of modules.........
Is This A Good Question/Topic? 0
  • +

Replies To: Brief Description of Module in VB

#2 JackOfAllTrades  Icon User is online

  • Saucy!
  • member icon

Reputation: 5954
  • View blog
  • Posts: 23,221
  • Joined: 23-August 08

Re: Brief Description of Module in VB

Posted 19 January 2010 - 06:44 AM

Moved from VB6 Tutorials to VB6.
Was This Post Helpful? 0
  • +
  • -

#3 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 463
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Brief Description of Module in VB

Posted 19 January 2010 - 07:07 AM

well public functions can be called without declaring variable as the module for example:
in module you have public function
Public Function Count_To_10() As Integer
	Dim i As Integer
	'init. the result of the function to be 0'
	Count_To_10 = 0
	For i = 1 To 10
		Count_To_10 = Count_To_10 + 1 'sum 1 every time till i=10'
	Next
End Function




now colling it to display the result on label
Private Sub cmdCountModul_Click()
	Label1.Caption = Count_To_10 'counting to 10 using module function'
End Sub




if you call it from class you have to do something like that
in class1 you have public function to count to 10
Public Function Count_to_10_cls() As Integer
	Dim i As Integer
	'init. count_to_10_cls result to 0
	Count_to_10_cls = 0
	For i = 1 To 10
		Count_to_10_cls = Count_to_10_cls + 1 'sume every time till i=10'
	Next i
End Function




to display it you need to do this
Private Sub cmdCount_CLS_Click()
	'count to 10 using class'
	Dim cCout As New Class1 'int a varaible as new class1'
	Label1.Caption = cCout.Count_to_10_cls  'count to 10 using class'
End Sub



remember if you made a public function in module you can call it every where in your project so do not replicate the name of the public functions or error will show up

here is a test program to see what i mean debug it

Attached File(s)


This post has been edited by NoBrain: 19 January 2010 - 07:35 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1