Alyce Alyce Apr 19, 2010 - "Edit for spelling and formatting."

[[toc]] =Displaying Multi-Line Text= //by [[user:StPendl|1271661732]]// > EveryEvery now and then one needs to display text of multiple lines, which the user should not be able to change. > Using one STATICTEXT control for each line is cumbersome, but the STATICTEXT control is a multi-line control with automatic text wrapping, which mostcontrol. Many programmers are not aware of.that a static control has automatic text line wrapping. > TheThe following are some ways to display multiple lines of text. ==Using a Static Text Control== > ThisThis allows the user to read the text, but he can notcannot select and copy anything.the contents. The text is broken into separate lines by adding a carriage-return character when a new line is desired. The carriage-return character is character 13 and is specified with the CHR$() statement as CHR$(13). [[code format="vbnet"]] ' turn main window off nomainwin ' specify text to display Message$ = "The world is turning"; CHR$(13); _ "till"until it gets stuck"; CHR$(13); _ "in the mud of the population." ' set up the GUI statictext #m.txt, Message$, 10, 10, 200, 100 ' open the window open "Multi-Line Message Demo" for window as #m ' trap closing the window, this line is mandatory #m "trapclose [quit]" ' wait for user action wait [quit] ' close the window and terminate close #m end [[code]] ==Using a Text Box with Scroll-Bar== > ThisThis allows the user to read the text and he can select and copy anything. > You can display a whole plain text file in a small space. [[code format="vbnet"]] ' turn main window off nomainwin ' specify text to display filedialog "Open a Plain Text File ...", "*.txt;*.bas", FileName$ ' no file selected then terminate if FileName$ = "" then end ' read the text open FileName$ for input as #f Message$ = input$(#f, lof(#f)) close #f ' set up the GUI textbox #m.txt, 10, 10, 200, 100 ' add a scroll bar for vertical scrolling and make the control read-only ' remove automatic horizontal scrolling stylebits #m.txt, _WS_VSCROLL or _ES_READONLY, _ES_AUTOHSCROLL, 0, 0 ' open the window open "Multi-Line Message Demo" for window as #m ' trap closing the window, this line is mandatory #m "trapclose [quit]" ' fill the text box #m.txt Message$ ' wait for user action wait [quit] ' close the window and terminate close #m end [[code]]