really strange error

  • Thread starter Thread starter robertmccall
  • Start date Start date
R

robertmccall

Greetings all,

I've been working and reworking some legacy vb.net 1.1 code for a
couple of months now and have just encountered an un-googleable error:

Expression is not an array or a method, and cannot have an argument
list.

This is happening for the Mid fct call in the following block of code:

dim tStr,uStr as string
tStr = "abc def ghi"
uStr = Mid( tStr, 1, 1 )

Now, this code is contained within a case block of a select case
statement.

The imports for the file are:

imports System
imports System.Data
imports System.Data.SqlClient
imports System.Text
imports Microsoft.Office.Interop

The file is parsing an Excel spreadsheet.

Other files in my project use the Mid fct without issue, and if I
prefix Mid with "Microsoft.VisualBasic.", everything is ok.

Anyone have any clues? I'm thoroughly stumped.

Thanks in advance,
Robert McCall
 
Well, that was quick: I had a class member variable named mId (one of
my favorites), and the case-insensitivity of VB got me. C# is much
more to my liking, but, excuses aside, sorry for the bandwidth.
 
hi Robert,

how about:

uStr = Microsoft.VisualBasic.Mid(tStr, 1, 1)

?

-t

robertmccall ha scritto:
 
robertmccall said:
I've been working and reworking some legacy vb.net 1.1 code for a
couple of months now and have just encountered an un-googleable error:

Expression is not an array or a method, and cannot have an argument
list.

This is happening for the Mid fct call in the following block of code:

dim tStr,uStr as string
tStr = "abc def ghi"
uStr = Mid( tStr, 1, 1 )

Now, this code is contained within a case block of a select case
statement.

The imports for the file are:

imports System
imports System.Data
imports System.Data.SqlClient
imports System.Text
imports Microsoft.Office.Interop

The file is parsing an Excel spreadsheet.

Other files in my project use the Mid fct without issue, and if I
prefix Mid with "Microsoft.VisualBasic.", everything is ok.

Right-click 'Mid' and choose "Go to Definition". Which type is shown? If
it's not 'Microsoft.VisualBasic.Strings', then a type clash exists and you
need to qualify 'Mid' either using 'Microsoft.VisualBasic.Strings' or
'Microsoft.VisualBasic'.
 
I you are going to use Visual Basic functions a lot like Mid, left, etc, then
as easy way to do it is to add an imports statement with an alias;

Imports VB = Microsoft.VisualBasic

then, use VB.Mid(.... or VB.Left(....
 
Back
Top