Display Listbox item's description in a Textbox [Resolved]
Hi all, I'm new to VB and this is my question:
I have a list box where the user select an item from the list box, and the description of the item will be display in a text box.
Different item will display different description in the same text box. How can I do this?
I've been trying by using this code:
VB Code:
Private Sub List1_Click()
Select Case List1.ListIndex
Case 0:
Text1.Text = "A Description"
Case 1:
Text1.Text = "B Description"
Case 2:
Text1.Text = "C Description"
End Select
End Sub
But the description is very long (more than hundreds words), I tried to store it in an access database, but failed because text size too large. Is it possible to save the description in a .txt file and load the description from that .txt file into the text box?
Thanks in advance!
Display Listbox item's description in a Textbox
Thanks Phreak, it works~! But the text shown up all in one paragraph even though it's originally divided in paragraphs in the text file. How can I make the text separated into paragraphs?
By the way, I changed the code
VB Code:
Open "C:\test.txt" For Input As #FF
to
VB Code:
Open "test.txt" For Input As #FF
in order the program to locate the file in the same folder as the project, and it works. Will this code still works when I converted my project into .exe file?
Printting description of the Textbox
VB Code:
Private Sub cmdPrint_Click()
'Print the Description
Printer.Font.Name = "Times New Roman"
Printer.Font.Size = 11
Printer.Print Text1.Text
Printer.EndDoc
End Sub
I wrote these code to print the description in the text box and the output is like it can't print the text as what it shown in the text box or text file. Certain lines in a paragraph were skipped until a suppose to be long document (description) printed as short/uncompleted. Well, I'm not sure if it really "skipped" the lines in a paragraph or it can't wrap the lines to fit the page.