We help IT Professionals succeed at work.

row is not a member of system.windows.forms.control

satishbethi asked
I am currently working on Migration of VB6 app to VB.Net, I had error in following line.
For iCounter = 1 To frmProfiles.DefInstance.Controls(sControlName).Row - 1 Step 1
Watch Question

Top Expert 2015
What are you trying to do exactly?

It looks as if you want to loop through the rows in a DataGridView or some similar control, but if this is so, a few things are not right.

Can't you directly use the control by its name, something like DataGridView1.Row? Usually, you use Controls when you cannot do that for some reason, but what you can do then is limited.

I do not know of any control where you use Row alone. It is usually either Rows or Row(number). And if you want to loop through the rows as I suspect, it would be Rows.Count.

Tell us what you are trying to do, and we should be able to help.

This being said, seeing that DefInstance, I suspect that you have converted you VB6 application directly to .NET. This is garbage. Unless you have a very simple application, you will spend a great deal of time trying to make it work and will succeed only if you are lucky. And you will not learn VB.NET. Nobody uses DefInstance in "real" code. Only the converter uses it, to try to make your application works as it did in VB6. VB.NET is very different.

You are usually better to rewrite your application. Believe me, it looks as if it will take longer, but it won't. Most people who use the converter end up losing time going round and round before the drop everything and restart from scratch.

Finally, when you ask a question about VB.NET, do not put VB Script in the topics. VB Script has absolutely nothing to do with VB.NET. They both have VB in their name, but it is like saying that you want to play your VHS tape in your new Blu-Ray player because they both have movies on them.