I would like to have an array in a structure in VB.NET just like we do in C++

struct MyThing { uchar color[4]; }

but it seems as if you can't have an array in VB.NET inside a structure?

Started by Jan 12 2011 08:11 AM

,
6 replies to this topic

Posted 12 January 2011 - 08:11 AM

Hi,I'm totally new to VB.NET.

I would like to have an array in a structure in VB.NET just like we do in C++

but it seems as if you can't have an array in VB.NET inside a structure?

I would like to have an array in a structure in VB.NET just like we do in C++

struct MyThing { uchar color[4]; }

but it seems as if you can't have an array in VB.NET inside a structure?

Sig: http://glhlib.sourceforge.net

an open source GLU replacement library. Much more modern than GLU.

float matrix[16], inverse_matrix[16];

glhLoadIdentityf2(matrix);

glhTranslatef2(matrix, 0.0, 0.0, 5.0);

glhRotateAboutXf2(matrix, angleInRadians);

glhScalef2(matrix, 1.0, 1.0, -1.0);

glhQuickInvertMatrixf2(matrix, inverse_matrix);

glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);

glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

an open source GLU replacement library. Much more modern than GLU.

float matrix[16], inverse_matrix[16];

glhLoadIdentityf2(matrix);

glhTranslatef2(matrix, 0.0, 0.0, 5.0);

glhRotateAboutXf2(matrix, angleInRadians);

glhScalef2(matrix, 1.0, 1.0, -1.0);

glhQuickInvertMatrixf2(matrix, inverse_matrix);

glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);

glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Posted 12 January 2011 - 08:34 AM

Hi,I'm totally new to VB.NET.

I would like to have an array in a structure in VB.NET just like we do in C++struct MyThing { uchar color[4]; }

but it seems as if you can't have an array in VB.NET inside a structure?

Keep in mind that a struct in C++ is pretty much the same thing as a class, whereas in .NET a structure is a value type, stored on the stack and a class is a reference type. Honestly, you're probably better off doing:

Public Class MyThing Public color() as Char = Nothing Public Sub New() ReDim color(4) End Sub End Class

That should achieve the same goal.

**Edited by Tape_Worm, 12 January 2011 - 08:54 AM.**

Posted 12 January 2011 - 08:52 AM

But that is a pain in the but. I am converting code to VB.NET (don't ask me why, it's not my choice).

I would have to track down all the places that need a New() call.

There must be a better way.

I would have to track down all the places that need a New() call.

There must be a better way.

Sig: http://glhlib.sourceforge.net

an open source GLU replacement library. Much more modern than GLU.

float matrix[16], inverse_matrix[16];

glhLoadIdentityf2(matrix);

glhTranslatef2(matrix, 0.0, 0.0, 5.0);

glhRotateAboutXf2(matrix, angleInRadians);

glhScalef2(matrix, 1.0, 1.0, -1.0);

glhQuickInvertMatrixf2(matrix, inverse_matrix);

glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);

glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

an open source GLU replacement library. Much more modern than GLU.

float matrix[16], inverse_matrix[16];

glhLoadIdentityf2(matrix);

glhTranslatef2(matrix, 0.0, 0.0, 5.0);

glhRotateAboutXf2(matrix, angleInRadians);

glhScalef2(matrix, 1.0, 1.0, -1.0);

glhQuickInvertMatrixf2(matrix, inverse_matrix);

glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);

glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Posted 12 January 2011 - 09:26 AM

You can store arrays in VB.NET's structures (the same way as you declare arrays anywhere else, as demonstrated by Tape_Worm), but cannot easily set a fixed size as you would in C.

A better way would likely be to use the Color structure in place of the array.

A better way would likely be to use the Color structure in place of the array.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Posted 12 January 2011 - 10:20 AM

Is there a RGBA form of that Color thing?

Sig: http://glhlib.sourceforge.net

an open source GLU replacement library. Much more modern than GLU.

float matrix[16], inverse_matrix[16];

glhLoadIdentityf2(matrix);

glhTranslatef2(matrix, 0.0, 0.0, 5.0);

glhRotateAboutXf2(matrix, angleInRadians);

glhScalef2(matrix, 1.0, 1.0, -1.0);

glhQuickInvertMatrixf2(matrix, inverse_matrix);

glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);

glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

an open source GLU replacement library. Much more modern than GLU.

float matrix[16], inverse_matrix[16];

glhLoadIdentityf2(matrix);

glhTranslatef2(matrix, 0.0, 0.0, 5.0);

glhRotateAboutXf2(matrix, angleInRadians);

glhScalef2(matrix, 1.0, 1.0, -1.0);

glhQuickInvertMatrixf2(matrix, inverse_matrix);

glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);

glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Posted 12 January 2011 - 12:11 PM

It is ARGB

an open source GLU replacement library. Much more modern than GLU.

float matrix[16], inverse_matrix[16];

glhLoadIdentityf2(matrix);

glhTranslatef2(matrix, 0.0, 0.0, 5.0);

glhRotateAboutXf2(matrix, angleInRadians);

glhScalef2(matrix, 1.0, 1.0, -1.0);

glhQuickInvertMatrixf2(matrix, inverse_matrix);

glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);

glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);