Hi i want to put 4 lines which will appear in a msg box but i can't do it. i have already used "<br />" but it doesn't work. i want the phrase to be one on each line. aneed help plz

Dani AI

Generated

A quick clarification that ties the replies together: HTML markup (for example a <br/> tag) is only interpreted by a browser when it renders HTML. Native dialog functions and simple client alerts do not parse HTML, so line breaks must be provided as actual newline characters. pointed this out for desktop code; that advice is correct for Windows/VB.NET dialogs. For ASP.NET pages you also need to make the text reach the browser (server-side MsgBox does not produce a browser dialog).

For a desktop VB/VB.NET dialog you can use VB newline constants when building the string:

' VB.NET desktop
MsgBox("Line 1" & vbCrLf & "Line 2" & vbCrLf & "Line 3")

For a web page, emit client-side script so the browser shows the dialog. Example using a startup script (works for a normal postback):

Dim script As String = "alert('Line 1\nLine 2\nLine 3');"
ClientScript.RegisterStartupScript(Me.GetType(), "showMsg", script, True)

If the page uses UpdatePanel, use ScriptManager.RegisterStartupScript instead.

Practical tips: escape single/double quotes inside the injected JavaScript, convert numbers to strings before concatenation, and prefer rendering the order summary in the page (a Literal or a modal dialog) for a better user experience than repeated alerts. gave the correct direction for newlines; the important extra point is to choose the correct output target (desktop dialog vs. browser) so line breaks are actually respected.

Recommended Answers

All 4 Replies

hi,
can u be more specific.

"I want each phrase to be one under each other like this. But in vain all appear on the same line. Need help plzzzz"

i want the message box to display:

'You have selected to buy:
3inch Screen MP4 / MP3 Player 2G. Total: Rs 5500
MP3 Player Sunglasses 1GB. Total: Rs 5000
The Orginal Apple Ipod 80GB . Total:Rs 11000
Total Price of buying product: Rs 21500
An email has been sent to you to confirm your order.
Thanks for buying our product. Do Come Again!'

Here is my code:

a = "You have selected to buy: "

If CheckBox1.Checked Then
If txtQuantity.Text = "" Then
MsgBox("Please enter your quantity for MP4/Mp3 Player", 64, "Message Error")
CheckBox1.Checked = False

Else
count = count + txtQuantity.Text
If count > 6 Then
MsgBox("You can't order more than 6", 64, "Message Error")
CheckBox1.Checked = False
txtQuantity.Text = ""
Else
totaladd = txtQuantity.Text * 5500
order = order & "3inch Screen MP4 / MP3 Player 2G. Total: " & totaladd
total = (total + totaladd)
End If

End If
End If


If CheckBox2.Checked Then
If txtQuantity2.Text = "" Then
MsgBox("Please enter your quantity for MP3 Sunglasses", 64, "Message Error")
CheckBox2.Checked = False

Else
count = count + txtQuantity2.Text
If count > 6 Then
MsgBox("You can't order more than 6")
CheckBox2.Checked = False
txtQuantity2.Text = ""
Else
totaladd = txtQuantity2.Text * 5000
order = order & " MP3 Player Sunglasses 1GB. Total:" & totaladd
total = (total + totaladd)
End If

End If
End If


If CheckBox3.Checked Then
If txtQuantity3.Text = "" Then
MsgBox("Please enter your quantity for Apple Ipod")
CheckBox3.Checked = False

Else
count = count + txtQuantity3.Text
If count > 6 Then
MsgBox("You can't order more than 6")
CheckBox3.Checked = False
txtQuantity3.Text = ""
Else
totaladd = txtQuantity3.Text * 11000
order = order & " The Orginal Apple Ipod 80GB . Total: " & totaladd
total = (total + totaladd)
End If

End If

End If
MsgBox(a & order & " TotalPrice of buying product: " & total & ". An email has been sent to you to confirm your order. Thanks for buying our product. Do Come Again!", 64, "New Technologie")

End Sub

Thanks dr

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.