Solved

Defining Byte Array size in Structures

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
location of a form 2 25
VB.NET Textbox input validation 4 41
Crystal reports login after closing form 3 17
Code enhancement 4 22
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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…

828 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