I'm trying to understand how to optimize myself using OOP code.
This is my attempt at a project i'm working on to manage IIS for me.

I'm trying to make a class that does what i want, and is actually well built, not crappy programming. Tell me what you think, what i need to improve and such. Also if you have any book reccommendations for coding classes in Vb, i'd appreciate anything.

VB Code:
  1. Imports System.DirectoryServices
  2.  
  3. Public Class WebDir
  4.  
  5.     Private m_SiteNumber As Integer
  6.     Private m_DirName As String
  7.     Private m_DirPath As String
  8.     Private m_Computer As String
  9.  
  10.     Public Sub New(ByVal DirName As String, ByVal DirPath As String)
  11.         m_Computer = "localhost"
  12.         m_SiteNumber = 1
  13.         m_DirName = DirName
  14.         m_DirPath = DirPath
  15.  
  16.     End Sub
  17.  
  18.     Public Sub New(ByVal Computer As String, ByVal SiteNumber As Integer, ByVal DirName As String, ByVal DirPath As String)
  19.         m_Computer = Computer
  20.         m_SiteNumber = SiteNumber
  21.         m_DirPath = DirPath
  22.         m_DirName = DirName
  23.  
  24.     End Sub
  25.  
  26.  
  27.     Public Sub Create()
  28.         Try
  29.             Dim IISRoot As DirectoryEntry
  30.             Dim NewDirectory As DirectoryEntry
  31.             IISRoot = New DirectoryEntry("IIS://" & m_Computer & "/W3SVC/" & m_SiteNumber & "/" & "Root")
  32.             NewDirectory = IISRoot.Children.Add(m_DirName, "IIsWebVirtualDir")
  33.             With NewDirectory
  34.                 .Properties("Path")(0) = m_DirPath
  35.                 .CommitChanges()
  36.             End With
  37.         Catch ex As Exception
  38.             Console.WriteLine(ex.Message)
  39.         End Try
  40.     End Sub
  41.  
  42.     Public Sub Delete()
  43.         Dim IISRoot As DirectoryEntry
  44.         Dim directory As DirectoryEntry
  45.         Try
  46.             IISRoot = New DirectoryEntry("IIS://" & m_Computer & "/W3SVC/" & m_SiteNumber & "/Root")
  47.             directory = IISRoot.Children.Find(m_DirName, "IIsWebVirtualDir")
  48.         IISRoot.Children.Remove(directory)
  49.         Catch ex As Exception
  50.             Console.WriteLine(ex.Message)
  51.         End Try
  52.     End Sub
  53.  
  54.     'returns the IIS service number of the FTP site on the server located at Computer
  55.     'returns -1 if could not be found
  56.     Public Sub FindSite(ByVal Name As String)
  57.  
  58.  
  59.  
  60.         Dim IISRoot As DirectoryEntry
  61.         Dim IISRootchildren As DirectoryEntries
  62.         Dim site As DirectoryEntry
  63.         Try
  64.             IISRoot = New DirectoryEntry("IIS://" & m_Computer & "/W3SVC")
  65.             IISRootchildren = IISRoot.Children
  66.  
  67.             For Each site In IISRootchildren
  68.                 If site.SchemaClassName = "IIsWebServer" Then
  69.  
  70.                     'check to see if the IIS number matches
  71.                     If site.Name.ToString() = Name Then
  72.                         m_SiteNumber = site.Name
  73.                         Exit Sub
  74.                     End If
  75.  
  76.  
  77.                     'first check to see if the server comment matches
  78.                     If site.Properties("ServerComment")(0) = Name Then
  79.                         m_SiteNumber = site.Name
  80.                         Exit Sub
  81.                     End If
  82.  
  83.                     'if not, let's look at the IP address
  84.  
  85.                     Dim ServerBindings As String
  86.                     Dim one As String
  87.                     Dim two As String
  88.                     Dim ia As String
  89.                     Dim ip As String
  90.                     Dim hn As String
  91.  
  92.                     ServerBindings = site.Properties("ServerBindings")(0)
  93.  
  94.                     one = InStr(ServerBindings, ":")
  95.                     two = InStr(CType((one + 1), Integer), ServerBindings, ":")
  96.  
  97.  
  98.                     ia = Mid(ServerBindings, 1, (one - 1))
  99.                     ip = Mid(ServerBindings, (one + 1), ((two - one) - 1))
  100.                     hn = Mid(ServerBindings, (two + 1))
  101.  
  102.                     If ia = Name Then
  103.                         m_SiteNumber = site.Name
  104.                         Exit Sub
  105.                     End If
  106.                 End If
  107.             Next
  108.         Catch ex As Exception
  109.             Console.WriteLine(ex.Message)
  110.         End Try
  111.  
  112.         m_SiteNumber = -1
  113.  
  114.  
  115.     End Sub
  116.  
  117. End Class