title: vb.net Executing the same sub two times with different arguments
body: <p>I have this sub that generates an csv file from the result of a query</p>
  
  <pre><code>Private Sub generaReport(classe As String)
  
      Dim query As String = "select bla bla bla"
  
      Dim dt As New System.Data.DataTable()
      Using con As New SqlConnection(My.Settings.dbstartConnectionString)
          Using cmd As New SqlCommand(query, con)
              cmd.Parameters.AddWithValue("@ieri", dataDa)
              cmd.Parameters.AddWithValue("@domani", dataA)
              cmd.Parameters.AddWithValue("@classe", classe)
              Using sda As New SqlDataAdapter(cmd)
                  sda.Fill(dt)
              End Using
          End Using
      End Using
  
      Dim elencoCsv As String = ToCSV(dt)
  
      If classe = "D" Then
          File.Delete(nomeFileCsvD)
  
          Using writer As New StreamWriter(nomeFileCsvD, True)
              writer.WriteLine(elencoCsv)
          End Using
      Else
          File.Delete(nomeFileCsvV)
  
          Using writer As New StreamWriter(nomeFileCsvV, True)
              writer.WriteLine(elencoCsv)
          End Using
      End If
      InvioEmail(My.Settings.emails)
  
      End
  End Sub
  </code></pre>
  
  <p>I would call it two times like </p>
  
  <pre><code>  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
              generaReport("D")
              generareport("V")
     End Sub
  </code></pre>
  
  <p>but the second time it runs it still use "D" as parameter. How can I solve this? Thanks</p>