title: How to create an instance of a string VB.Net
body: <p>Okay, I'm making this program that automatically gets the username and password from my remote  ftp server, and logs in. But it's giving me an error that says "Object reference not set to an instance of an object"</p>
  
  <p>Here is a sample of my code:</p>
  
  <pre><code>    Imports System.Net
      Imports System.Net.FtpClient
      Public Class Form1
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      Using ftp = New FtpClient()
          Dim credentials As New NetworkCredential
          ftp.Host = "my ftp server"
          credentials = ftp.Credentials
          Dim username As String
          username = credentials.UserName.ToString 'Object reference not set to an instance of an object
          Dim password As String
          password = credentials.Password.ToString
      End Using
  End Sub    
  </code></pre>