Calling Public Function

tk.unlimited

Active member
Joined
Apr 2, 2005
Messages
27
Programming Experience
1-3
How would i call this public function

Module ArrayStuff

Public Sub copyListboxToIntArray(ByVal theList As ListBox, ByVal theArr() As Integer)

Dim iLimit As Integer

Dim iItemNo As Integer

iLimit = theList.Items.Count

For iItemNo = 0 To (iLimit - 1)

theArr(iItemNo) =
CInt(theList.Items(iItemNo))

Next

End Sub

Public Function gradingofIntarray(ByVal theArr() As Integer) As String

Dim icount As Integer

Dim ilimit As Integer

Dim iaMark As Integer

Dim igrading As String

ilimit = theArr.Length

For icount = 0 To (ilimit - 1)

iaMark = theArr(icount)

If iaMark < 0 Then

igrading = ("??")

Else

If iaMark >= 0 And iaMark < 50 Then

igrading = ("NN")

Else

If iaMark >= 50 And iaMark < 60 Then

igrading = ("PA")

Else

If iaMark >= 60 And iaMark < 70 Then

igrading = ("CR")

Else

If iaMark >= 70 And iaMark < 80 Then

igrading = ("DI")

Else

If iaMark >= 80 And iaMark <= 100 Then

igrading = ("HD")

Else

If iaMark > 100 Then

igrading = ("??")

End If

End If

End If

End If

End If

End If

End If

Return igrading

Next icount

End Function

End
Module

I want to display it in a listbox so the Grading (HD, DI etc) is input into a listbox when the items are added...
 
A module is essentially a class where all members are shared, so you call a public method of a module like you would a public shared method of a class. In your case this would be:
VB.NET:
[size=2]ArrayStuff.[/size][size=2]copyListboxToIntArray([/size][size=2]listBox, integerArray[/size][size=2])[/size]
Note that you will have to pass parameters ByRef if you want them to be affected by the operation.
 
Last edited:
Back
Top