microsoft.public.dotnet.languages.vb.data,microsoft.public.dotnet.languages.vb.controls,microsoft.pu

  • Thread starter Thread starter Gladys
  • Start date Start date
G

Gladys

Dear newsgroup - do not reply to this e-mail address. I have just
created it to avoid getting spam to my real address. Reply to the
newsgroup. I am watching them all now so please reply now.


How do I get a list of methods that my class supports? Here is my
code.
I want

MsgBox(a.GetMethods, MsgBoxStyle.Information Or MsgBoxStyle.OKOnly,
a.GetVersion)

to display, if a is a "TanOperations", "getTan1, getTan2". If a is a
"SinOperations", "getSin" etc.

To help you I am using Visual Studio .net 2003.

Thank you
Gladys



Imports System.Math

Public Class Form1
Inherits System.Windows.Forms.Form

Private MustInherit Class Trigonometry
Public Shared Function GetVersion() As String
Return "V1.0.1"
End Function

Public Function GetMethods() As String()
'WHAT CODE GOES IN HERE??
'=========================

End Function
End Class

Private Class TanOperations
Inherits Trigonometry
Public Function getTan1(ByVal opp As Double, ByVal adj As
Double) As Double
Return Tan(opp / adj)
End Function

Public Function getTan2(ByVal theta As Double) As Double
Return Tan(theta)
End Function
End Class

Private Class SinOperations
Inherits Trigonometry
Public Function getSin(ByVal opp As Double, ByVal hypot As
Double) As Double
Return Sin(opp / hypot)
End Function
End Class

'windows form designer code deleted to save posting space


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim a As New TanOperations
MsgBox(a.getTan(10, 20), MsgBoxStyle.Information Or
MsgBoxStyle.OKOnly, a.GetVersion)
MsgBox(a.GetMethods, MsgBoxStyle.Information Or
MsgBoxStyle.OKOnly, a.GetVersion)
End Sub
End Class
 
You can use reflection:

Dim t As Type = GetType(MyClass)
For Each methodInfo As System.Reflection.MethodInfo _
In t.GetMethods
MsgBox(methodInfo.Name)
Next
 
* (e-mail address removed) (Gladys) scripsit:
[...]

Are you sure you understood the meaning of the "Subject:" line?
 
Back
Top