Results 1 to 4 of 4

Thread: Ideas on how to return value and alter array [Resolved]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2004
    Posts
    102

    Resolved Ideas on how to return value and alter array [Resolved]

    Lo all, Im after some ideas on how I can do something. In my program a client connects to my server app. The server app recieves the data in a byte array which needs to be sorted into like Bytes, Int16, Int32, Strings etc etc. Anyway Ive made some functions to join parts of the byte array to make my Int16, Int32 and strings etc but I want to also remove what Ive just joined together from the array. eg.

    Array is this first of all
    Arr(0) = 1
    Arr(1) = 2
    Arr(2) = 3
    Arr(3) = 4
    Arr(4) = 5
    Arr(5) = 6

    I call the function say GetInt32(Arr) this would then return 1234
    Then Id like the function to adjust array accordingly ie

    Array is now
    Arr(0) = 5
    Arr(1) = 6

    Is there anyway to do it within the function 'GetInt32'. I know I could just make another function to do it but Id love to get it into the same function but I dont think You can return 2 values lol. Any ideas
    Last edited by Dilvid; Nov 14th, 2005 at 02:48 AM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Ideas on how to return value and alter array

    Note that you are going to have to pass your array ByRef regardless of how you achieve this, because you are going to have to create a new array object. You could either create a new array of the appropriate size and then copy the appropriate elements, or you could add the array to a collection using AddRange, then Remove the appropriate items and then copy back to a new array.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    Re: Ideas on how to return value and alter array

    Post your function as it is now, and we can tell you how to make it adjust for size..

    Bill
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2004
    Posts
    102

    Re: Ideas on how to return value and alter array

    I got it sorted now, I just made a class called packet which had all the functions to get certain values and also a function to make the array smaller. I just pass the class location around instead of just the array

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width