passing array error

  • Thread starter Thread starter Darin
  • Start date Start date
D

Darin

dim arr_file(100) as string
dim cnt as integer=0
cnt += 1
arr_file(cnt-1)="file1"

if something is true then
cnt += 1
arr_file(cnt-1)="file2"
endif

if something2 is true then
cnt += 1
arr_file(cnt-1)="file3"
endif

sendstuff(to, from, arr_file) '***


The sendstuff:

public sub sendstuff(byval in_to as string, _
byval in_from as string, _
byval paramarray in_files() as string)


on *** line, the arr_file is showing:

value of type '1-dimensional array of string' cannot be converted to
string.

Darin
 
Darin said:
dim arr_file(100) as string
dim cnt as integer=0
cnt += 1
arr_file(cnt-1)="file1"

if something is true then
cnt += 1
arr_file(cnt-1)="file2"
endif

if something2 is true then
cnt += 1
arr_file(cnt-1)="file3"
endif

sendstuff(to, from, arr_file) '***


The sendstuff:

public sub sendstuff(byval in_to as string, _
byval in_from as string, _
byval paramarray in_files() as string)


on *** line, the arr_file is showing:

value of type '1-dimensional array of string' cannot be converted to
string.

If I write

Dim in_to, in_from As String

sendstuff(in_to, in_from, arr_file)

I do not get that error, neither in VB 2003 nor in VB 2008,
 
the error is not because of the first two arguments, the error is on the
last argument as it shows:

sendstuff(to, from, arr_file)

and arr_file has the blue line under it. placing the cursor over the
arr_file the error message is displayed.

VS2005

Darin
 
I am an idiot.
i had an extra argument in my sub.
sorry.

Darin

*** Sent via Developersdexhttp://www.developersdex.com***

That's why it's important to post the exact code rather than trying to
type it from memory. If you had posted the actual code, the problem
would have been obvious.
 
Back
Top