There's a couple of ways:orCode:For Counter As Integer = 0 to ListBox.Items.Count - 1 Messagebox.Show(ListBox.Items(Counter).ToString) NextCode:Messagebox.Show(ListBox.GetItemText(ListBox.Items(ListBox.SelectedIndex)))
|
|
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
There's a couple of ways:orCode:For Counter As Integer = 0 to ListBox.Items.Count - 1 Messagebox.Show(ListBox.Items(Counter).ToString) NextCode:Messagebox.Show(ListBox.GetItemText(ListBox.Items(ListBox.SelectedIndex)))
Currently using: VS 2005 & 2008 Pro w/sp1 & VS 2010 Ultimate on Win7 Ultimate x64.
There are 3 kinds of people in the world: Those who can count and those who can't.
4 out of 3 people have trouble with fractions.
Windows has a 64 bit GUI for a set of 32 bit extensions on a 16 bit shell for an 8 bit OS using a 4 bit kernel made by a 2 bit company that can't stand 1 bit of competition.
This shows how to send each line to a txt file then print it automatically:
And this for sending it to a specific printer:Code: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()
Code:Proc.StartInfo.Verb = "PrintTo" Proc.StartInfo.Arguments = """" & Printer_Name & """"
Close Counts for Horseshoes, Handgranades, and Nuclear Missiles!
If he's wanting to print something, this is probably the worst way I've ever seen it done.
There's the PrintDocument and PrintDialog that's already in the Framework for printing to a printer, he can even use the PrintPreview or the PrintPreviewDialog control for testing and debugging the print routines without actually sending it to the printer.
But since he hasn't explained what he wants done, all I did was show him how he can get the text of the item(s) in the ListBox.
Currently using: VS 2005 & 2008 Pro w/sp1 & VS 2010 Ultimate on Win7 Ultimate x64.
There are 3 kinds of people in the world: Those who can count and those who can't.
4 out of 3 people have trouble with fractions.
Windows has a 64 bit GUI for a set of 32 bit extensions on a 16 bit shell for an 8 bit OS using a 4 bit kernel made by a 2 bit company that can't stand 1 bit of competition.
Well that was kinda viscous! What up JB?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
Close Counts for Horseshoes, Handgranades, and Nuclear Missiles!
Currently using: VS 2005 & 2008 Pro w/sp1 & VS 2010 Ultimate on Win7 Ultimate x64.
There are 3 kinds of people in the world: Those who can count and those who can't.
4 out of 3 people have trouble with fractions.
Windows has a 64 bit GUI for a set of 32 bit extensions on a 16 bit shell for an 8 bit OS using a 4 bit kernel made by a 2 bit company that can't stand 1 bit of competition.
Yeah, so I just threw out an idea. I don't see anything wrong with my approach - if I don't want to bug the user with another dialog box when I know what I want to do and it works just fine for that. Yes we needed more info, but I did not mind offering up an idea anyway. There are many ways to skin a cat - but to flat criticize it... If it is so wrong tell me why. I am self taught and when I research things there is nothing there to me this way is the jacked up way.
Close Counts for Horseshoes, Handgranades, and Nuclear Missiles!
cheers for all the help, right or wrong, i appreciate the time to answer! ill let you know which one works best for me when im back at college in a few days![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks