Solved

Defining Byte Array size in Structures

Posted on 2008-06-26
1
739 Views
Last Modified: 2011-09-20
Using Visual Basic 2005, I am trying to define a Structure with two byte arrays. I am trying to set these Byte Arrays to a fixed size, but VB complains that Arrays declared in structure members cannot be declared with an initial size. How do I get round this problem...?


Thanks in advance.

Public Structure FT_DEVICE_LIST_INFO_NODE

        Dim Flags As Integer

        Dim Type As Integer

        Dim ID As Integer

        Dim LocID As Integer

        Dim SerialNumber(16) As Byte 'VB complains here 

        Dim Description(32) As Byte 'and here

        Dim Handle As Integer

    End Structure

Open in new window

0
Comment
Question by:fvcctv
1 Comment
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 21876469
Hi fvcctv;

Here is how to initialize arrays in a structure.

Public Class Form1

    Public Structure FT_DEVICE_LIST_INFO_NODE
        Dim Flags As Integer
        Dim Type As Integer
        Dim ID As Integer
        Dim LocID As Integer
        Dim SerialNumber() As Byte 'VB complains here
        Dim Description() As Byte 'and here
        Dim Handle As Integer
    End Structure

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim ft As New FT_DEVICE_LIST_INFO_NODE()
        ReDim ft.SerialNumber(16)
        ReDim ft.Description(32)

    End Sub


End Class


Fernando
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now