Syntax for a new line

Status
Not open for further replies.

claire_bicknell

Well-known member
Joined
Dec 10, 2008
Messages
49
Programming Experience
Beginner
I know this is probably a really REALLY simple question but i just can't figure it out!

This is my code so far:

HTML:
Private Sub LoadPlaces()
        Me.CentreTableAdapter.Fill(MyDataSet, "Centre")
        For Each row As DataRow In MyDataSet.Tables("Centre").Rows
            places.Add(row.Item("CentreName") & (" ") & ("Address: ") & row.Item("Address") & (" ") & ("Phone: ") & row.Item("TelephoneNumber") & (" ") & ("Opening Times: ") & row.Item("OpeningClosingTimes"), New Rectangle(row.Item("X1"), row.Item("Y1"), row.Item("X2"), row.Item("Y2")))


        Next
    End Sub

And I am asking the question in regards to this fragment of code in particular:

HTML:
places.Add(row.Item("CentreName") & (" ") & ("Address: ") & row.Item("Address") & (" ") & ("Phone: ") & row.Item("TelephoneNumber") & (" ") & ("Opening Times: ") & row.Item("OpeningClosingTimes"), New Rectangle(row.Item("X1"), row.Item("Y1"), row.Item("X2"), 
row.Item("Y2")))

I want the result to be like this:

Trafford Park
Address: ...........
Telephone: ............
Opening Times: ...........

Currently it is just one long string and I need to put the syntax for a new line in the correct places.

Any help much appreciated.
 
I would use a StringBuilder, and also the strongly typed dataset, it should be something like this:
VB.NET:
Me.CentreTableAdapter.Fill(Me.MyDataSet.Centre)
For Each row As MyDataSet.CentreRow In Me.MyDataSet.Centre.Rows
    Dim s As New System.Text.StringBuilder
    s.AppendLine(row.CentreName)
    s.AppendLine("Address: " & row.Address)
    s.AppendLine("Phone: " & row.TelephoneNumber)
    s.AppendLine("Opening Times: " & row.OpeningClosingTimes)
    places.Add(s.ToString, New Rectangle(row.X1, row.Y1, row.X2, row.Y2))
Next
I think I would also save each rectangle to a single string column, using RectangleConverter to convert to and from, example:
VB.NET:
Dim c As New RectangleConverter
Dim r As New Rectangle(1, 2, 3, 4)
Dim s As String = c.ConvertToString(r)
r = CType(c.ConvertFromString(s), Rectangle)
 
@JohnH is correct and also work so fine

you can also use
VB.NET:
vbcrlf
for new line

VB.NET:
places.Add(row.Item("CentreName") & vbcrlf & ("Address: ") & row.Item("Address") & vbcrlf  & ("Phone: ") & row.Item("TelephoneNumber") & vbcrlf & ("Opening Times: ") & row.Item("OpeningClosingTimes"), New Rectangle(row.Item("X1"), row.Item("Y1"), row.Item("X2"), 
row.Item("Y2")))
 
Status
Not open for further replies.

Latest posts

Back
Top