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

  • SEARCH
  • Home
  • 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 7443425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:19:41+00:00 2026-05-29T11:19:41+00:00

Please have a look at the following code, which I have run in VB6

  • 0

Please have a look at the following code, which I have run in VB6 and .NET:

Private Sub Form_Load()
Dim TestArray3() As String
TestArray3 = TestArrayFunction

End Sub

Private Function TestArrayFunction() As String()
    Dim TestArray1(0 To 1) As String
    Dim TestArray2() As String
    TestArray1(0) = "Monday"
    TestArray1(1) = "Tuesday"
    TestArray2 = TestArray1
    TestArray1(0) = "Wednesday"
End Function

When the program gets to the end of TestArrayFunction in VB6, the value of TestArray2(0) is “Monday”, however when run in .NET, it is “Wednesday”. I understand in .NET that an Array is an object and has two references pointing to it in TestArrayFunction. Why is this not the case in VB6?

  • 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-29T11:19:41+00:00Added an answer on May 29, 2026 at 11:19 am

    I am struggling with this nearly daily. While it is perfectly possible to pass an array ByRef to a Function call, the ‘=’ sign will make a shallow copy.

    But there is more strange behaviour of arrays in VB6, Suppose you have the following DateTimeClass classmodule in VB6:

    Option Explicit
    
    Private m_strDaysOfWeek() As String
    
    Public Property Get DaysOfWeek() As String()
    
        DaysOfWeek = m_strDaysOfWeek()
    
    End Property
    
    Public Property Let DaysOfWeek(strDaysOfWeek() As String)
    
        m_strDaysOfWeek() = strDaysOfWeek
    
    End Property
    
    Private Sub Class_Initialize()
        ReDim m_strDaysOfWeek(7)
        m_strDaysOfWeek(1) = "Monday"
    End Sub
    

    You would expect to be able to write code like:

    Dim clsDateTime As New DateTimeClass
    Dim strDay As String
    
    strDay = clsDateTime.DaysOfWeek(1)
    

    Or:

    clsDateTime.DaysOfWeek(2)="Tuesday"
    

    But you can’t. You have to do it like this:

    Dim clsDateTime As New DateTimeClass
    Dim strDay As String
    Dim strDays() As String
    
    strDays = clsDateTime.DaysOfWeek
    strDay = strDays(1)
    strDays(2) = "Tuesday"
    clsDateTime.DaysOfWeek = strDays
    

    What the reasons of the VB6 team were at the time to implement it thus? I don’t know…
    I have abandoned the VB6 arrays and use Collections and Dictionaries nearly exclusively.

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

Sidebar

Related Questions

am new here. i have a slight problem; PLease look at the following code
Please have a look at the code below: import string from collections import defaultdict
Please have a look at the following code: #include <stdio.h> #include <stdlib.h> typedef struct
Please have look on the following code: $_SESSION[process_y] = new Process(); $process_y = $_SESSION[process_y];
Please have a look a the following code sample, executed on a Windows-32 system
Please have a look at the following code: <HTML> <HEAD> <script src=//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js type=text/javascript></script> <SCRIPT
please have a look at the following code: (I removed all doctypes etc for
i was dealing with the following code,& got confused,please have a look at it
In my current project, Workflows have comments. Please have a look at the following
Please have a look on the code below .. <div id=click_me>Save</div> <div id=blocks_sortable> <div

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.