• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 780
  • Last Modified:

Defining Byte Array size in Structures

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
fvcctv
Asked:
fvcctv
1 Solution
 
Fernando SotoCommented:
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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Tackle projects and never again get stuck behind a technical roadblock.
Join Now