Solved

Defining Byte Array size in Structures

Posted on 2008-06-26
1
735 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

20 Experts available now in Live!

Get 1:1 Help Now