View Full Version : VB.net line breaks

01-23-2007, 04:15 AM
Hey guys, I'm new to the world of programming.I'm working in vb.net and I'm trying to generate an error message based on what is strored in the variable.
The code is as follows:
Dim ErrMsg as string

If (txt_fname.text = "") then

ErrMsg ="Please enter the following information:" & vbCrLf & "first name"

End if

and so it goes on checking for rest of the empty fields and updating the ErrMsg variable. The problem is that the line break is not working.What am I doin wrong?

01-23-2007, 09:47 AM
Although 'vbCrLf' should work fine...
Just try '<br>' or '\n' for the heck of it...

How are you displaying the ErrMsg ?
Label... or MsgBox... or something else...

01-23-2007, 06:48 PM
Well <br> worked, thanks.But just wondering why vbCrlf did'nt work.This is how I am generating the error message.I'm not using a label or message box.

<%if ErrMsg<>"" then%>
<td colspan="2" align="left" valign="top" style="background-color:#FFFF00;color:red"><%=ErrMsg%></td>
<%end if%>

01-25-2007, 02:50 PM
In case you are displaying in a browser, you have to include html code to generate markup like a linebreak.

If you use vbCrLf, the linebreak will only be in the output by the serverside code, meaning: the sourcecode of your page (you can check this with view source). This doesn't render automatically to a linebreak in the viewed page.