The console output produces exactly what I'm looking for, however I'm not sure how to get that format to the richtextbox. Even with the padding in place, the righ "column" of data still doesn't line up cleanly as in my second example from the first post.

Re: Aligning array output in a richtextbox

Posted 30 June 2011 - 07:39 AM

Have you thought about using a ListView control and using the columns. You could produce pretty close to the same effect you're describing. Just remove the column headers and change some selection settings. Just a thought in case you're open to other suggestions.

EDIT:

Just messing around, here is how it looks taking your array and putting it into columns in a listview.

2 columns, second column is right justified.
Column Headers are turned off

Re: Aligning array output in a richtextbox

Posted 30 June 2011 - 09:51 AM

CharlieMay, on 30 June 2011 - 06:39 AM, said:

Have you thought about using a ListView control and using the columns. You could produce pretty close to the same effect you're describing. Just remove the column headers and change some selection settings. Just a thought in case you're open to other suggestions.

EDIT:

Just messing around, here is how it looks taking your array and putting it into columns in a listview.LVColumns.JPG

2 columns, second column is right justified.
Column Headers are turned off

Details view.

That looks exactly what I'm going for, but this is for an assignment for school and I have strict requirements of what I supposed to do. I must sort the two 1d arrays and display the sorted results to a richtextbox. If this is something I can do with a listview, then I will check it out.

hawkvalley1, on 30 June 2011 - 05:45 AM, said:

This is most likely in a loop - right? You change the 15 to whatever works.

Re: Aligning array output in a richtextbox

Posted 30 June 2011 - 10:27 AM

What is with Tutor and insisting on using multiple 1D arrays? for conveying different fields of an subject.
Doesn't this suggest, that you're going about thing wrong.
Encapsulate the fields into a class.

Public Class Movie_BoxOffice
Protected _Title As String
Protected _BoxOffice As Long
Public Sub New(ByVal Title As String, ByVal BoxOffice As Long)
_Title = Title : _BoxOffice = BoxOffice
End Sub
Public ReadOnly Property Title() As String
Get
Return _Title
End Get
End Property
Public ReadOnly Property BoxOffice() As Long
Get
Return _BoxOffice
End Get
End Property
End Sub
End Class

So much easier to use.

Dim Movies() = {
New Movie_BoxOffice("From Russia with Love ",555909803),
New Movie_BoxOffice("Dr. No",425488741),
New Movie_BoxOffice("From Russia with Love",555909803),
New Movie_BoxOffice("Goldfinger",868659354),
New Movie_BoxOffice("Thunderball",966435555),
New Movie_BoxOffice("You Only Live Twice",720388023),
New Movie_BoxOffice("On Her Majesty's Secret Service",513445231)
}
Dim ByBox = From Movie In Move OrderBy Movie.BoxOffice Descending

Re: Aligning array output in a richtextbox

Posted 30 June 2011 - 06:02 PM

AdamSpeight2008, on 30 June 2011 - 10:27 AM, said:

What is with Tutor and insisting on using multiple 1D arrays? for conveying different fields of an subject.
Doesn't this suggest, that you're going about thing wrong.
Encapsulate the fields into a class.

Public Class Movie_BoxOffice
Protected _Title As String
Protected _BoxOffice As Long
Public Sub New(ByVal Title As String, ByVal BoxOffice As Long)
_Title = Title : _BoxOffice = BoxOffice
End Sub
Public ReadOnly Property Title() As String
Get
Return _Title
End Get
End Property
Public ReadOnly Property BoxOffice() As Long
Get
Return _BoxOffice
End Get
End Property
End Sub
End Class

So much easier to use.

Dim Movies() = {
New Movie_BoxOffice("From Russia with Love ",555909803),
New Movie_BoxOffice("Dr. No",425488741),
New Movie_BoxOffice("From Russia with Love",555909803),
New Movie_BoxOffice("Goldfinger",868659354),
New Movie_BoxOffice("Thunderball",966435555),
New Movie_BoxOffice("You Only Live Twice",720388023),
New Movie_BoxOffice("On Her Majesty's Secret Service",513445231)
}
Dim ByBox = From Movie In Move OrderBy Movie.BoxOffice Descending

Hey, I appreciate your input. Unfortunately the class I take is part of a University program and I'm not sure how much control he has over the curriculum. While I'm sure your method is easier to implement and makes more sense, unfortunately, I don't think the instructor is going to bend on this topic...

Re: Aligning array output in a richtextbox

Posted 30 June 2011 - 06:58 PM

Thanks everyone for the assistance! Below is the code I am using. Hawk, As you stated, I switched the richtextbox's font to a fixed-width font (courier) and the following works great! Thanks again everyone!!