Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 893001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:09:01+00:00 2026-05-15T14:09:01+00:00

I have a simple VB.NET form that acts as an interface to a control

  • 0

I have a simple VB.NET form that acts as an interface to a control library with a public API.

One of the API calls takes an array of UIntegers ByRef:

Public Function Get_Values(source_id As Byte, first_value_address As Byte, number_of_values As Byte, ByRef valuesOut As UInteger()) As Integer

After the call, valuesOut will hold a list of values number_of_values long from source_id starting at first_value_address.

There is a hardware-driven limitation that the maximum number of values returned is 15 regardless of requested length. I need to get 28 values into an array from my VB.NET code.

Is it possible to send only part of an array variable to the function similar to the following C code?

uint[28] values;
Get_Values(0, 0, 15, values); // Get first part
Get_Values(0, 15, 13, &values[15]); // Get second part of data
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T14:09:01+00:00Added an answer on May 15, 2026 at 2:09 pm

    No, what you’re specifically asking for is not possible. Unlike C/C++-style arrays (which, simplified are just blocks of memory equal to sizeof(Type) * n, where n is the number of elements), .NET arrays cannot be referred to or offset by pointer arithmetic*. As a result, if the public API does not provide you with a way to indicate an offset in the array, then you’re going to have to pass intermediate arrays to the function and reassemble them yourself once you’ve finished.

    You could, however, wrap the call in your own version of the function:

    public int GetValues(byte source_id, byte first_value_address, byte number_of_values, uint[] buffer, int offset)
    {
        uint[] temp = new uint[number_of_values];
    
        int retValue = GetValues(source_id, first_value_address, number_of_values, temp);
    
        Array.Copy(temp, 0, buffer, offset, number_of_values);
    
        return retValue;
    }
    

    It should also be noted that ByVal and ByRef represent calling conventions, not whether or not the type is a value type. Unless you have a specific reason to (and here it appears that you do not), you don’t need to specify ByRef on your array argument. The only type ByRef is required is when the function will change the actual value of the variable and you want that reflected in the calling code. The way that you’re calling it, it appears that you allocate the array, pass it to the function, then use its contents. The only time the function would be modifying the variable’s value is if it set it equal to a different array instance; simply changing the array values does not require ByRef in order for the calling code to see the results.

    **Unless you actually use unsafe code and do pointer-based arrays yourself, but that’s outside the scope of your question*

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pretty simple ASP.NET Web Form that looks a bit like the
I have a simple form on an ASP.NET MVC site that I'm building. This
I have a simple Windows Form application that is using the .net 3.5 compact
C sharp newbie question...I have a simple asp.net form that has a textbox that
I have a simple ASP.NET form with a DropDownList and two RadioButtons (that both
I have a simple web form that sends and email out via .NET C#.
I have a simple .NET 2.0 windows form app that runs off of a
I have a simple in VB/ASP.NET form containing two text boxes, I am attempting
I have an ajax form in asp.net mvc which is as simple as this:
Help me, Stackoverflow! I have a simple .NET 3.5 console app that reads some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.