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 9028215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:55:53+00:00 2026-06-16T06:55:53+00:00

I wrote the following code: Public Class Form1 Private Structure udtThing Dim SomeText As

  • 0

I wrote the following code:

Public Class Form1

Private Structure udtThing
    Dim SomeText As String
    Dim SomeElements() As String
    Public Shared Function CreateInstance() As udtThing
        Dim result As New udtThing
        result.SomeText = String.Empty
        ReDim result.SomeElements(2)
        result.SomeElements(0) = String.Empty
        result.SomeElements(1) = String.Empty
        result.SomeElements(2) = String.Empty
        Return result
    End Function
End Structure

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Dim nThings() As udtThing
    nThings = Array.CreateInstance(GetType(udtThing), 10)

End Sub
End Class

I partly works, nThings becomes an array of 11 udtThings.
But .SomeElements is not redimmed to 3 strings of String.Empty, but it is “Nothing” instead.

Does anybody see where I went wrong?

Thank you very much!

  • 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-06-16T06:55:54+00:00Added an answer on June 16, 2026 at 6:55 am

    By design, a Redim is required. Array.CreateInstance() isn’t going to perform that operation, it can’t guess what size is required. You’ll have to help:

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim nThings(10) As udtThing
        For ix As Integer = 0 To UBound(nThings)
            nThings(ix) = udtThing.CreateInstance()
        Next
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote the following code: public class Log { public static void Info(string message,
I wrote the following code: public class Point2 { private double _radius , _alpha;
I wrote the following code. [XmlRoot(myxml)] public class myxml { [XmlElement(one)] public string one
I wrote the following code: import java.lang.*; import DB.*; private Boolean validateInvoice(String i) {
I have the following code: public partial class Form1 : Form { public BindingList<Class>
I wrote the following code: public class UserAccountWebServices { @Context protected HttpHeaders httpHeaders; @HeaderParam(Authorization)
How would I write the following C# code in F#? namespace Shared { public
I wrote following code...but i am getting Error like: Error 1 'LoginDLL.Class1.Login(string, string, string)':
I wrote the following code to count the node of an XML file: private
I did the following: public partial class Form1 : Form { public UserControl uc

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.