tags:

views:

118

answers:

1

I am working on fixing a bug in VB that is giving this error. I am new to VB, so there is some syntax that I am not fully understanding. The code that is throwing the error says:

.Row(itemIndex).Item("parentIndex") = CLng(oID) + 1000000

I understand that adding 1000000 is too much for an int16. I can't change that value (not right now anyway). What I don't understand, and can't seem to find, is what .Row is referring too. Any ideas?

A: 

Hi there.

Next to the .Row do you see a With keyword?

With allows you to do stuff like this:

With myClass
   .FirstName  ="John"
End With

Which is the same as this:

myClass.FirstName = "John"

Usually you will use a With block if you have a lot of references to the same object. For example:

myClass.FirstName = "John"
myClass.FirstName = "John"
myClass.FirstName = "John"
myClass.FirstName = "John"
myClass.FirstName = "John"

can be changed to this:

With myClass
  .FirstName = "John" 
  .FirstName = "John"
  .FirstName = "John"
  .FirstName = "John"
  .FirstName = "John"
End With

EDIT:

I copied and pasted the above code, hence the repeated use of the property FirstName. Cheers. Jas.

Jason Evans
Yes, I was just about to post that it is wrapped in a with. So that is what .Row refers too then huh. Good to know. Now I just need to fix the error message. Thanks.
Barlow Tucker
Likely the .Row is connected to a grid, or a DataTable? The first line of the With block will help you with figuring this out.
Jason Evans