Solved

Defining Byte Array size in Structures

Posted on 2008-06-26
1
765 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 63

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

691 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