.net - How to print a multi-lined string into a message box? -
i trying print 'last receipt' customer in have stored sting variable called prevrecpt.
i want able press button (btnlastreceipt) , display sting in message box.
is possible? have tried , ended message box showing first line?
prevrcpt = "--------------------butlers cinemas--------------------" & environment.newline prevrcpt = prevrcpt & tbtime.text & environment.newline prevrcpt = prevrcpt + "operator: " + tbuser.text & environment.newline prevrcpt = prevrcpt + environment.newline & environment.newline + "-------------------------------------------------------" prevrcpt = prevrcpt + "total spent: £" + tbtotal.text + environment.newline + environment.newline prevrcpt = prevrcpt + shoppingcart.text + environment.newline prevrcpt = "--------------------butlers cinemas--------------------" & environment.newline
this code building string.
have tried concatenating environment.newline
anywhere in string?
now can see code, seems last line should instead:
prevrcpt = prevrcpt & "--------------------butlers cinemas--------------------" & environment.newline
that being said, need aware in event of long string, message box size out of screen bounds, may want use else messagebox
. if possible, make own dialog form, make default size convenient scenarios , use scrollable text zone within it. readonly textbox
multiline
property set true
not scrollable, also allow end user copy content in clipboard. may make user's experience lot better.
i should mention stringbuilder
class , few constants make code lot cleaner:
const headerorfooter string = "--------------------butlers cinemas--------------------" const separator string = "-------------------------------------------------------" dim b new text.stringbuilder() b.appendline(headerorfooter) b.appendline(tbtime.text) b.appendformat("operator: {0}", tbuser.text) b.appendline() b.appendline() b.appendline() b.appendline(separator) b.appendformat("total spent: £{0}", tbtotal.text) b.appendline() b.appendline(shoppingcart.text) b.appendline(headerorfooter) prevrcpt = b.tostring()
Comments
Post a Comment