473,656 Members | 2,756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Populating Structure Arrays

If you define a structur
Private Structure Str
Dim X as Intege
Dim Y as Strin
End Structur

Is there a way to populate the structre when you define the array
Dim XX() as StrX = Str((1,'A'), (2,'B')

Thank

David
Nov 20 '05 #1
2 1964
CT
Well, you could something like this, adding a constructor with the required
parameters:

Private Structure StrX
Dim X As Integer
Dim Y As String

Sub New(ByVal xParam As Integer, ByVal yParam As String)
X = xParam
Y = yParam
End Sub
End Structure

and when intializing something like this:

Dim XX() As StrX = New StrX() {New StrX(1, "a"), New StrX(2, "b")}

--
Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
"David Stephen" <an*******@disc ussions.microso ft.com> wrote in message
news:81******** *************** ***********@mic rosoft.com...
If you define a structure
Private Structure StrX
Dim X as Integer
Dim Y as String
End Structure

Is there a way to populate the structre when you define the array.
Dim XX() as StrX = Str((1,'A'), (2,'B'))

Thanks

David

Nov 20 '05 #2
CT
Well, you could something like this, adding a constructor with the required
parameters:

Private Structure StrX
Dim X As Integer
Dim Y As String

Sub New(ByVal xParam As Integer, ByVal yParam As String)
X = xParam
Y = yParam
End Sub
End Structure

and when intializing something like this:

Dim XX() As StrX = New StrX() {New StrX(1, "a"), New StrX(2, "b")}

--
Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
"David Stephen" <an*******@disc ussions.microso ft.com> wrote in message
news:81******** *************** ***********@mic rosoft.com...
If you define a structure
Private Structure StrX
Dim X as Integer
Dim Y as String
End Structure

Is there a way to populate the structre when you define the array.
Dim XX() as StrX = Str((1,'A'), (2,'B'))

Thanks

David

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
4034
by: Friday | last post by:
Sorry if this is the wrong group. I tried to find the one I thought would be most relevant. I'm an old PHP guy, who knows little about asp and NOTHING about asp.net, but need to learn at least enough to convert a favorite PHP script to work on an ASP.NET site. I'm experimenting with simple example scripts that will help me learn how to implement each "piece" of the puzzle.
2
4840
by: Steve Turner | last post by:
I have read several interesting posts on passing structures to C dlls, but none seem to cover the following case. The structure (as seen in C) is as follows: typedef struct tag_scanparm { short cmd; short fdc; WORD dsf; short boxcar; short average; short chan_ena;
0
267
by: David Stephen | last post by:
If you define a structur Private Structure Str Dim X as Intege Dim Y as Strin End Structur Is there a way to populate the structre when you define the array Dim XX() as StrX = Str((1,'A'), (2,'B') Thank
4
2507
by: Chuck Ritzke | last post by:
Okay, just when I thought I was starting to understand stuff. In VB6... Type MyDataType Dim Value1 as double Dim Value2 as double End Type Dim MyData1 as MyDataType Dim MyData2 as MyDataType
2
1951
by: James | last post by:
Hi, I need help with a couple of questions, I have create and structure like: Structure byteArray Public byteA() As Byte End Structure Public ptrArray() As byteArray
3
6035
by: sck10 | last post by:
Hello, I am creating a form for users to enter information about a lab and the members of the lab. I have one form (FormView) that they use to enter information about that lab. The keyvalue is "LabLocation_ID". With an existing lab, they then need to add the members for that lab. So, what I am trying to do is the following. With the FormView of the Lab open, the user will click a button to open a FormView (InsertMode) and add a new...
14
1785
by: Dennis | last post by:
If I have a structure like; Public Structure myStructureDef Public b() as Byte Public t as String End Structure If I pass this structure, will the values in the array b be stored on the stack or will just a pointer to the array be stored on the stack? I am trying to decide whether to use Structures or Pointers. I know that M'soft
10
4984
by: David Fort | last post by:
Hi, I'm upgrading a VB6 app to VB.net and I'm having a problem with a call to a function provided in a DLL. The function takes the address of a structure which it will fill in with values. I get an error: ---------------- An unhandled exception of type 'System.NullReferenceException' occured in
8
2540
by: jack-b | last post by:
Hi, I have a list box which displays countries names and a second listbox which displays their cites (based on the selection made in ListBox 1) If the user selects USA i want to display cities in the States - if the user selects multiple countries I want to display the cities in ALL the selected counties e.g. a user select US and England, the second list would display ally cities in England and all the cities in the US.
0
8297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8498
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7311
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1930
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1600
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.