title: Is there some way to automatically indent VB.NET code in a text file
body: <p>I would like to correctly indent some VB.NET code contained within a text file. Is there some way to do this?</p>
  
  <p>e.g.
  Start with this:</p>
  
  <pre><code>Public Shared Function CanReachPage(page As String) As Boolean
  Try
  Using client = New WebClient()
  Using stream = client.OpenRead(page)
  Return True
  End Using
  End Using
  Catch
  Return False
  End Try
  End Function
  </code></pre>
  
  <p>finish up with this:</p>
  
  <pre><code>Public Shared Function CanReachPage(page As String) As Boolean
      Try
          Using client = New WebClient()
              Using stream = client.OpenRead(page)
                  Return True
              End Using
          End Using
      Catch
          Return False
      End Try
  End Function
  </code></pre>
  
  <p>Everything I have searched for has so far led me to the <a href="http://msdn.microsoft.com/en-us/library/system.codedom.compiler.indentedtextwriter%28v=vs.110%29.aspx" rel="nofollow noreferrer">IndentedTextWriter</a> Class but the only examples I have found are to manually indent lines like this: <a href="https://stackoverflow.com/questions/2547428/net-console-textwriter-that-understands-indent-unindent-indentlevel">.NET Console TextWriter that Understands Indent/Unindent/IndentLevel</a></p>
  
  <p>Extra credit: I would also like to add the correct spacing as well if possible:</p>
  
  <p>e.g <code>Dim i As String="Hello"+"GoodBye"</code>  -> <code>Dim i As String = "Hello" + "GoodBye"</code></p>