2. First I opened a called a SaveFile dialog to get a file path. I then initialized a StreamWriter and used StreamWriter.Write(Textbox.Text) to write to the file.
I then closed the stream using StreamWriter.Close()
3. Yes, I used a for loop to write the listbox into a file. You can write a for loop to write every item of the listbox from 0 until listbox.items.count . This code will work for any length listbox and is much more condensed than if I had chosen not to use a for loop.
4. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
dlgSave.ShowDialog()
Dim sW As IO.StreamWriter
If dlgSave.FileName() <> "" Then
sW = IO.File.CreateText(dlgSave.FileName)
Dim i As Integer
For i = 0 To ListBox1.Items.Count - 1
sW.WriteLine(ListBox1.Items.Item(i))
Next i
sW.Close()
End If
End Sub
5. Sean Henley
6. Private Function TotalCost()
Dim i
Dim TC As Double
For i = 0 To 11
TC += ListBox1.Items.Item(i).ToString.Substring(ListBox1.Items.Item(i).ToString.IndexOf("$")) * (-i + 12)
Next i
Return Format(TC, "currency")
End Function