Jump to content

  • Log In with Google      Sign In   
  • Create Account


Array in a structure. Visual Basic .NET


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 V-man   Members   -  Reputation: 805

Like
0Likes
Like

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++

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);

Sponsor:

#2 Tape_Worm   Crossbones+   -  Reputation: 1691

Like
0Likes
Like

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.


#3 V-man   Members   -  Reputation: 805

Like
0Likes
Like

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.
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);

#4 benryves   GDNet+   -  Reputation: 1992

Like
0Likes
Like

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.
[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

#5 V-man   Members   -  Reputation: 805

Like
0Likes
Like

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);

#6 SiCrane   Moderators   -  Reputation: 9490

Like
0Likes
Like

Posted 12 January 2011 - 10:26 AM

I don't understand your question; the Color structure he linked to does have R, G, B and A components.

#7 V-man   Members   -  Reputation: 805

Like
0Likes
Like

Posted 12 January 2011 - 12:11 PM

It is ARGB
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);




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS