Question:

VB.NET - I need to figure out how to set up these variables

by  |  earlier

0 LIKES UnLike

I have tought myself VB.NET over the last several years. I'd say I'm pretty decent at it, not super advanced but pretty good for someone who has never had a lesson.

Now here's the thing, I'm going to be wanting to create a variable that is an array. This variable needs to have the same number of indexes (not sure if that's the right word or not) as the number of videos imported into my app. Now, the user needs to be able to delete and add videos in real time, so the number of indexes needs to change dynamically without changing the contents.

Now, for the next part. I'm almost sure this is possible, but if it's not I could probably work around it somehow.

The same variable I mentioned above needs to somehow have sub-variables (again not sure what to call it) so that I can assign different properties to each video. It would be something like:

video(index).profile = "iPhone"

video(index).width = 640

video(index).height = 360

video(index).fps = 23.976

etc

how would I do something like this?

Thanks in advance.

 Tags:

   Report

2 ANSWERS


  1. Sounds like you need a "Video" class that's implemented with public fields of profile, width, height, etc. And then you just have an array of Video objects.

    These object-oriented features are new to VB.NET (compared to VB 6), so it might be a relatively new concept for you.


  2. You can use the feature called 'Structures'.

    With this structure you can have a package of several related variable as a single unit. The syntax is like this:

    Structure Video

       Dim profile As String

       Dim width As Integer

       Dim height As Integer

       Dim fps As Integer

    End Structure

    so these profile, width, height and fps will be called member. Then you can access the member exactly the way you did above.

    Hope this helps you with your projects

    Regards,

    Martin

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.