question: which statement has NO effect

roadrunner

New member
Joined
Oct 31, 2006
Messages
2
Programming Experience
Beginner
I was recently asked a multiple choice question: According to the sample code, which one of the following statements has NO effect and should be moved to another line to accomplish its purpose?
Code:
dim tb as New TextBox
g_row as Integer = 0
tb.Text = CType(g_row, String)
tb.Location = New Point(tb.Location.X, g_row * tb.Size.Height)
tb.BringToFront()
g_row += 1
Me.Listbox1.Parent.Controls.Add(tb)

A. g_row += 1
B. tb.BringToFront()
C. tb.Text = g_row
D. tb.Location = New Point(tb.Location.X, g_row * tb.Size.Height)
E. Me.Listbox1.Parent.Controls.Add(tb)

I don't know why C is there. What do you think the answer is and why?
 
this is obviously homework, so i'll explain it a little and let you come up with the answer:

first it declares tb as a textbox
then it declares g_row as an integer
now it's assigning the g_row to the textbox's text property
then it gives the textbox a location and brings it to the front
then it increments the g_row integer
and finally it adds the textbox to the listbox

i hope that helps clear it up
 
re: from roadrunner brainbench practice

This was a question from a brainbench practice test. It has no points associated with it. It was done on my own accord to sharpen my programming efficiency.
 
The answer is B. The control isn't on the form yet, there's nothing to move it in front of yet.... should be moved to after the Controls.Add call.

-tg
 
Back
Top