[Year 12 Its] VB.NET questions
Alex Hopkins
a.hopkins at bcc.vic.edu.au
Thu Jun 8 17:08:09 EST 2006
Dear Frank,
The following assumes a RichTextBox on a form.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myString As String
Dim val1 As Double
Dim val2 As Double
Dim formattedString As String
RichTextBox1.Text = String.Empty
myString = "Hello world"
val1 = 23.45
val2 = 67.89
formattedString = myString & ControlChars.Tab & val1.ToString & ControlChars.Tab & val2.ToString & ControlChars.CrLf
RichTextBox1.Text = formattedString
'If you want to take greater control, you can set the tab positions.
'Use code such as the following after inserting the needed text.
'The code here will set the tab stops for all the text in the rtb;
'if it is desired to set the tabs for only a portion of text,
'modify the SelectionStart and SelectionLength values.
Dim myTabs() As Integer = {30, 150, 250, 350, 450} 'Create an array of tab positions
RichTextBox1.SelectionStart = 0
RichTextBox1.SelectionLength = RichTextBox1.Text.Length
RichTextBox1.SelectionTabs = myTabs
'After applying the tabs,
RichTextBox1.SelectionStart = 0 'set the cursor position (SelectionStart) to zero
RichTextBox1.SelectionLength = 0 'set the length of the selection to zero
End Sub
But it's obviously not close to picOutput.print aword, i, i^2
One of the things I do when stumped on such things is to try vbCity, a forum where you can ask questions and usually get answers that are accurate and that arrive within a day. http://www.vbcity.com/forums/ You do need to log in to ask questions.
You can print text as graphics to a VB.Net form or control, but it wouldn't be any easier for students to understand. Some of my students wanted to know how to use a graphics object and really enjoyed exploring it, but I gather you're wanting something simpler than that solution.
Regards,
Alex Hopkins
----- Original Message -----
From: "Frank Van Den Boom" <vandenboomfj at aquinas.vic.edu.au>
To: <is at edulists.com.au>
Sent: Thursday, June 08, 2006 12:37 PM
Subject: [Year 12 Its] VB.NET questions
>I am currently retraining myself from very basic VB to very basic VB.NET. A question for more experienced VB.NET people out there...
>
> To print a formatted table with a string (eg aword) in column 1, integer (eg. i) in column 2, and integer in column 3 (eg i^2), VB6 can do it as follows, where picOutput is a picture box or a form.
>
> picOutput.print aword, i, i^2
>
> In VB.NET, the best I can do so far using a rich text box (txt1) is as follows. It seems the Print command is no longer supported in the previous form.
>
> txt1.Text = txt1.Text + aword.padright(15, " ") + CStr(i).PadLeft(4, " ") + CStr(i ^ 2).PadLeft(6, " ") + vbCrLf
>
> Can anyone suggest a simpler approach that is closer to the VB6 statement?
> While there's some good learning in understanding this statement for students, talk about trying to crack a walnut with a sledgehammer......
>
> Frank
>
> _______________________________________________
> http://www.edulists.com.au
> IT Systems Mailing List kindly supported by
> http://www.vcaa.vic.edu.au - Victorian Curriculum and Assessment Authority and
> http://www.vitta.org.au - VITTA Victorian Information Technology Teachers Association Inc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.edulists.com.au/pipermail/is/attachments/20060608/8f4c530a/attachment-0001.html
More information about the is
mailing list