Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / May 2006

Tip: Looking for answers? Try searching our database.

umanaged code - array error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Patrick Sullivan - 08 May 2006 15:51 GMT
dim s_err as stringbuilder
dim xx(6) as double
dim ret_flag as integer

' This is a function to call an unmanaged C-style library function.
' The lib function fills an array of 6 doubles or error string.

Declare Auto Function calc Lib "calc32.dll" Alias "calc32.dll"( ByRef xx()
As Double, ByVal serr As System.Text.StringBuilder) As Integer

' Using the unmanaged function:

ret_flag = swe_calc(tjd_et, planet, iflag, xx(6), serr)

If I take out the 6 in the above line, I get error "number of indices is
less than the number of dimensions in the indexed array."

If I put it in, or put a zero in, like xx(0) or xx(6), I get the error
"value of type double cannot be converted to '1 dimensional array of
double'"

What is wrong here? TIA

Signature

Patrick Sullivan, AA-BA, BA-IT

Patrick Sullivan - 08 May 2006 15:53 GMT
dim s_err as stringbuilder
dim xx(6) as double
dim ret_flag as integer

' This is a function to call an unmanaged C-style library function.
' The lib function fills an array of 6 doubles or error string.

Declare Auto Function calc Lib "calc32.dll" Alias "calc32.dll"( ByRef xx()
As Double, ByVal serr As System.Text.StringBuilder) As Integer

' Using the unmanaged function:

ret_flag = swe_calc(xx(6), serr)

If I take out the 6 in the above line, I get error "number of indices is
less than the number of dimensions in the indexed array."

If I put it in, or put a zero in, like xx(0) or xx(6), I get the error
"value of type double cannot be converted to '1 dimensional array of
double'"

What is wrong here? TIA
Larry Lard - 08 May 2006 16:18 GMT
> dim s_err as stringbuilder
> dim xx(6) as double
[quoted text clipped - 9 lines]
>
> ret_flag = swe_calc(xx(6), serr)

Copy-and-pasting code is a much more reliable way of showing us your
code. Note that the Declare calls the function 'calc' but you call it
as 'swe_calc'. If we have to guess what you mean, it will take us
longer to help you.

> If I take out the 6 in the above line, I get error "number of indices is
> less than the number of dimensions in the indexed array."
>
> If I put it in, or put a zero in, like xx(0) or xx(6), I get the error
> "value of type double cannot be converted to '1 dimensional array of
> double'"

Try

       ret_flag = calc(xx, serr)

The function wants an array: it is xx - not xx(0) or xx(6) or xx() -
that is an array.

Also, xx should be initialised to an empty array before calling the
DLL, otherwise there will be nowehere to put the results:

       xx = New Double(6) {}

Also also, all I have fixed is the syntax: I don't know enough about
calling unmanaged code to be able to say that this will definitely do
what you want.

Signature

Larry Lard
Replies to group please

Patrick Sullivan - 08 May 2006 16:34 GMT
Thanks Larry. You figured out what I wanted to know, I think. Interop is
kind of confusing. It took me quite a while to get the s_err to pass
compiling.

Signature

Patrick Sullivan, AA-BA, BA-IT

> > dim s_err as stringbuilder
> > dim xx(6) as double
[quoted text clipped - 37 lines]
> calling unmanaged code to be able to say that this will definitely do
> what you want.
Göran Andersson - 09 May 2006 14:19 GMT
You are declaring an array of 7 doubles. To declare an array of 6
doubles, you have to do like this:

dim xx(5) as double

> dim s_err as stringbuilder
> dim xx(6) as double
[quoted text clipped - 18 lines]
>
> What is wrong here? TIA

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.