0

This code works:

gErrorHandler.Push("frmItemcodes.cmdRunMethodOne_Click")
If gfHANDEL_ERRORS Then On Error GoTo PROC_ERR

Dim query = KQdbs.Items.Where(Function(f) f.Itemcode > 8000)
Me.dgvItemcodes.DataSource = query.ToList

PROC_EXIT:
    gErrorHandler.Pop()
    Exit Sub

PROC_ERR:
    gErrorHandler.HandleError()
    Resume PROC_EXIT

but if I change the literal 8000 to any kind of variable I get the following error:

Error BC36597 'On Error GoTo PROC_ERR' is not valid because 'PROC_ERR' is inside a scope that defines a variable that is used in a lambda or query expression.

I have no idea why

If I change the code in the body to this:

Dim query = From item In KQdbs.Items Where item.Itemcode = 8000
Me.dgvItemcodes.DataSource = query.ToList

The results are the same, the literal works a variable returns the same error as above

loudscott
  • 11
  • 2
  • Where do you declare and initialize this *any kind of variable*? By the way, you should (nearly) always avoid goto statements. – Gert Arnold Mar 03 '17 at 20:36
  • i initialize it in the very same method, doesn't work. What I really wish to do is use me.txtItemLookup.text which is a textbox on the form. As for the Goto this is pretty standard error handling that I used back in the day ('97 to 2001)...have things changed? – loudscott Mar 03 '17 at 20:43
  • 1
    Have things changed? You must be kidding. Exception handling in .Net can't be compared to the VB6 way. – Gert Arnold Mar 03 '17 at 20:48

0 Answers0