For Counter As Integer = 0 to ListBox.Items.Count - 1
Messagebox.Show(ListBox.Items(Counter).ToString)
Next
Messagebox.Show(ListBox.GetItemText(ListBox.Items(ListBox.SelectedIndex)))
Using sw As New StreamWriter(filePath & "mytestprint.txt")
For Each line As String In ListBox1.Items
sw.WriteLine(line)
Next
End Using
Dim Proc As New Process
Proc.StartInfo.FileName = filePath & "mytestprint.txt"
Proc.StartInfo.Verb = "Print"
Proc.StartInfo.CreateNoWindow = True
Proc.StartInfo.UseShellExecute = True
Proc.Start()
Proc.WaitForExit()
Proc.Dispose()
Proc.StartInfo.Verb = "PrintTo"
Proc.StartInfo.Arguments = """" & Printer_Name & """"
If he's wanting to print something, this is probably the worst way I've ever seen it done.This shows how to send each line to a txt file then print it automatically:
And this for sending it to a specific printer:VB.NET:Using sw As New StreamWriter(filePath & "mytestprint.txt") For Each line As String In ListBox1.Items sw.WriteLine(line) Next End Using Dim Proc As New Process Proc.StartInfo.FileName = filePath & "mytestprint.txt" Proc.StartInfo.Verb = "Print" Proc.StartInfo.CreateNoWindow = True Proc.StartInfo.UseShellExecute = True Proc.Start() Proc.WaitForExit() Proc.Dispose()
VB.NET:Proc.StartInfo.Verb = "PrintTo" Proc.StartInfo.Arguments = """" & Printer_Name & """"
i have made a basic program for college which makes a calculation and diplays the information in a listbox, how do i then print that text?
really appreciate any help
Sure, print the text to what? A MessageBox? The screen? A control on the form? A printer? He didn't specify anything.Well that was kinda viscous! What up JB?