Welcome to CrankyGoblin.Com Sign in | Join | Help

Public Class GeoffAppleby

Inherits Microsoft.VisualBasic.MVP : Implements IBrainFart
My VB example code.

This is the code I wrote in VB that I'm going to learn to convert to IL all by my very self.

<Assembly: AssemblyTitle("MyILTest")>
<Assembly: AssemblyDescription("This is the VB code that I'm going to learn to convert to IL")>
<Assembly: AssemblyCompany("Geoff Inc.")>
<Assembly: AssemblyProduct("VBConsoleApp")>
<Assembly: AssemblyCopyright("Hands off")>
<Assembly: AssemblyTrademark("Hands off(tm)")>
<Assembly: CLSCompliant(True)>
<Assembly: Guid("948684E5-F1D6-4F9F-B6E8-E28D20E8101D")>
<Assembly: AssemblyVersion("1.0.*")>

Public Interface ISimpleInterface
  Sub SimpleSub()
  Function SimpleFunction() As Int32
End Interface

Public Interface IMediumInterface
  Inherits ISimpleInterface

  Sub MediumSub(ByVal firstArgument As Int32)
  Function MediumFunction(ByVal firstArgument As Int32) As Int32
End Interface

Public Interface IHardInterface
  Inherits IMediumInterface

  Function HardFunction(ByVal ParamArray numberSeries() As Int32) As IMediumInterface
  Sub HardSub(ByRef mediumVersion As IMediumInterface)
End Interface

Public Class SimpleClass
  Implements ISimpleInterface

  Public Sub SimpleSub() Implements ISimpleInterface.SimpleSub
    Console.WriteLine("This is a simple sub")
  End Sub

  Public Function SimpleFunction() As Int32 Implements ISimpleInterface.SimpleFunction
    Dim i As Int32
    Dim j As Int32

    i = 13
    j = i * 53

    Return j - i
  End Function
End Class

Public Class MediumClass
  Inherits SimpleClass
  Implements IMediumInterface

  Private mlArgument As Int32

  Public Sub MediumSub(ByVal firstArgument As Integer) Implements IMediumInterface.MediumSub
    Dim sMessage As String
    sMessage = String.Format("This is a medium sub - {0}, {1}", firstArgument, mlArgument)
    Console.WriteLine(sMessage)
  End Sub

  Public Function MediumFunction(ByVal firstArgument As Integer) As Integer Implements IMediumInterface.MediumFunction
    Dim lRet As Int32

    lRet = System.Convert.ToInt32(System.Math.Sqrt(firstArgument))
    mlArgument = firstArgument + 5

    Return lRet
  End Function
End Class

Public Class HardClass
  Inherits MediumClass
  Implements IHardInterface

  Public Sub HardSub(ByRef mediumVersion As IMediumInterface) Implements IHardInterface.HardSub
    mediumVersion = CType(Me, IMediumInterface)
  End Sub

  Public Function HardFunction(ByVal ParamArray numberSeries() As Int32) As IMediumInterface Implements IHardInterface.HardFunction
    Dim lTotal As Int32 = 0

    For Each lNumber As Int32 In numberSeries
      lTotal += lNumber
    Next

    If (lTotal And 123) = 123 Then
      Console.WriteLine(True)
    Else
      Console.WriteLine(False)
    End If

    Return New MediumClass
  End Function

  Public Property SomeProperty() As Boolean
    Get
      Return False
    End Get
    Set(ByVal Value As Boolean)
      Console.WriteLine(System.Convert.ToString(Value))
    End Set
  End Property
End Class

Module MainModule

  Public Sub Main()
    Dim oTest As New HardClass
    Dim oMediumClass As MediumClass
    Dim lArgument As Int32 = 13

    oTest.SimpleSub()
    oTest.SimpleFunction()

    oTest.MediumSub(oTest.MediumFunction(lArgument))

    oTest.HardSub(DirectCast(oTest, IMediumInterface))
    oMediumClass = CType(oTest.HardFunction(1, 2, 3, 4, 5), MediumClass)

  End Sub

End Module
Posted: Monday, 4 July 2005 4:37 AM by Geoff Appleby

Comments

Public Class GeoffAppleby said:

Over the last few weeks my interest in figuring out the inner workings of code has seemed to come to...
# July 4, 2005 4:53 AM

Public Class GeoffAppleby said:

As I wrote yesterday, I've decided to sit and down and teach myself enough IL to make myself understand...
# July 5, 2005 6:24 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

To submit your comment, click on these pictures:
  • Geoff the big mouth
  • Geoff's pretty blue eyes
  • Geoff's tongue
Gaptcha Image - No Peeking! Gaptcha Image - No Peeking! Gaptcha Image - No Peeking!
Gaptcha Image - No Peeking! Gaptcha Image - No Peeking! Gaptcha Image - No Peeking!
Gaptcha Image - No Peeking! Gaptcha Image - No Peeking! Gaptcha Image - No Peeking!
Can't recognise the people in these pictures? Look here for a quick introduction.
There's a time limit for you to get your comment submitted before this set of pictures expires. If you think it's been longer than 10 minutes, get some new pictures first (you won't lose what you've typed so far).
Get some new pictures 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS