RPG User Generated Item / Inventory System
RPG User Generated Item / Inventory System
RPG User Generated Item / Inventory System
RPG User Generated Item / Inventory System
RPG User Generated Item / Inventory System
RPG User Generated Item / Inventory System RPG User Generated Item / Inventory System RPG User Generated Item / Inventory System RPG User Generated Item / Inventory System RPG User Generated Item / Inventory System RPG User Generated Item / Inventory System RPG User Generated Item / Inventory System RPG User Generated Item / Inventory System
RPG User Generated Item / Inventory System RPG User Generated Item / Inventory System
RPG User Generated Item / Inventory System
Go Back  Xtreme Visual Basic Talk > > > RPG User Generated Item / Inventory System


Reply
 
Thread Tools Display Modes
  #1  
Old 02-15-2013, 12:29 PM
Under Study Under Study is offline
Regular
 
Join Date: Jul 2008
Posts: 83
Default RPG User Generated Item / Inventory System


Hey guys,

So I was trying to come up with the best way to make a sort of "end-less" or maybe better said as "seemingly end-less" Item system to a RPG style game. It would have your basic items(weapons / armor / tools ) that you can buy but also some that you have to make in game. In my head the this seems crazy huge as each weapon as so many variables. A dagger could be made out of 8 different materials, have 1 of 20 different quality types, up to 15 of 15 different enchantments, and all that can factor into its min/max damage and price. I want the user to feel like they have complete customizable control. So how do I get that without programing every one of these in by hand?

My idea was to create an array for every factor that goes into it and a bit of code that puts them all together into. so you give it a string of numbers and the code turns it into actually information.

Is there a simpler / smarter way?
Reply With Quote
  #2  
Old 02-16-2013, 02:54 AM
surfR2911 surfR2911 is offline
Contributor
 
Join Date: Oct 2009
Posts: 719
Default RPG Inventory System and tiems - a few options for coding..

First of all there aren't a lot of good (fully developed) examples of doing a RPG inventory system in VB.Net.

I would cite the examples that I did in this "sprite as what" thread as well as
the attachment to the final post #8 of the magnite7 thread that spawned the other thread.

Quote:
Originally Posted by Under Study
So how do I get that without programming every one of these in by hand?

My idea was to create an array for every factor that goes into it and a bit of code that puts them all together into.
so you give it a string of numbers and the code turns it into actually information.

Is there a simpler / smarter way?
If you are into manufacturing weapons (like daggers, swords, axes, etc) or even
other rpg items (potions, runestones, scrolls, etc) you of course can do it "by hand".
That's the way modern day renaissance faire people handcraft their items.

However, in terms of programming such items you also have the option of being a little more efficient
at "manufacturing" such items by an automated "factory" means.

What is the coding/programming equivalent of a "factory" (and/or an assembly line)?

It' s all about classes.

A class is a blueprint, or maybe it says it better on this off forum rpg items thread:
Quote:
A class is the blueprint for instantiating (making an instance of) the object.
Using such a blueprint each item "manufactured" can have variegated characteristics.
So even though the "template" can produce the blade and the hilt in a straightforwardly standard way,
you can introduce in the class a mechanism to alter the final product in various ways,
such that you end up with a collection of items, none of them identical.

Does this sound anything like something that might be worth investigating?



While arrays are "old school", have been around for a while (like in VB6), and still work in VB.Net,
there are other ways of storing bits of information a regularized way.

If you look at the attachments towards the end of the "sprite as what" thread, you see this:
Quote:
Code:
Private Structure SpriteType
    Public Pos As Rectangle
    Public SpriteBmp As Bitmap
    Public SpriteDragging As Boolean
End Structure

Private Structure SpriteContainer
    Public ContainsSprite As Boolean
    Public ContainerRect As Rectangle
    Public Index As SpriteType
End Structure
In case you are not familiar with Structures here's some links:
Using Classes and Structures in Visual Basic .NET
Structures (Visual Basic)

Of course there many storage collections in the System.Collections Namespace, and you could even use Enums (1, 2), but
whatever storage means you use I would recommend trying to integrate it with using a class,
(that is other than the type of class that is used in a VB.Net form).

Possibly related threat:
this "stupid question" thread (where I severely embarass myself) but has some good info from passel and others.

I hate threads that discuss "theory" and never give a code example so here's
one quick link that has a very basic (and short) rpg item class snippet:
Inventory system for RPG-type game in Visual Basic.

Oh and just to round out this post I should mention that a class can implement something
called an Interface (a non-visual code type) using a class.
This StackOverFlow thread has a rpg-based VB.Net code example if you need one.

Last edited by surfR2911; 02-16-2013 at 03:02 AM.
Reply With Quote
  #3  
Old 02-16-2013, 11:42 AM
Under Study Under Study is offline
Regular
 
Join Date: Jul 2008
Posts: 83
Default

Ok, so I get structures... just no clue how they could be used here. Maybe ive been thinking about this from this same prospective for so long that only this way makes sense....Sadly im not good enough to be right. Maybe you could give a little bit more of an example?

Here is a very quick code I wrote just as a proof of concept that my array method would work. I tried to add notes but I might have rushed though it a bit so if its sloppy and confusing, i apologize.

Basically i started a new form. Added a button and a Module. The only code on the form was in the click even of the button where i called the Public Sub Set_Weapon_Variables() event. Like I said, just a proof of concept.

Let me know what you think / if I can do this with Structures.

Thanks!!!

Code:
Module NewItemSystem

    '*Just a note* All of the arrays that are integers are not needed, only added in to be place holders 
    'so you can visualize how I see it set up, but basically only string arrays are needed for code to 
    'work. Normally integers can be plugged right in. Ill explain as I go. 


    'These 25 variables could all be part of one single weapon. If the weapon is special enough 
    'to have filled all 5 of its enchantment slots and it's name contains both a prefix and a suffix.
    'Normal store bought weapons would not have those. 

    'These first four variables can determinant the weapons name that the user will identify with the weapon. 
    'Basically placing the stings together one right after the other. (EX [Epic] [Iron] [Dagger] [Of the Void]) 
    Public strWeapon_Name_Prefix(20) As String
    Public strWeapon_Resource_Tyrpe(20) As String
    Public strWeapon_Type(50) As String
    Public strWeapon_Name_Suffix(20) As String



    ' What text will appear to the user when viewing this Weapon 
    Public strWeapon_Slot1_Enchantment_Name(20) As String

    ' Will be factored into the combat damage formula as what kind of damage the enchantment does
    Public StrWeapon_Slot1_Enchantment_Type(20) As String

    ' Again, not an actual variable, but there is a spot on the item info for this peace of information,
    ' and will be use in combat damage formula to set a level or intensity of the above affect. 
    Public intWeapon_Slot1_Enchantment_Amount(500) As Integer

    Public strWeapon_Slot2_Enchantment_Name(20) As String
    Public StrWeapon_Slot2_Enchantment_Type(20) As String
    Public intWeapon_Slot2_Enchantment_Amount(500) As Integer

    Public strWeapon_Slot3_Enchantment_Name(20) As String
    Public StrWeapon_Slot3_Enchantment_Type(20) As String
    Public intWeapon_Slot3_Enchantment_Amount(500) As Integer

    Public strWeapon_Slot4_Enchantment_Name(20) As String
    Public StrWeapon_Slot4_Enchantment_Type(20) As String
    Public intWeapon_Slot4_Enchantment_Amount(500) As Integer

    Public strWeapon_Slot5_Enchantment_Name(20) As String
    Public StrWeapon_Slot5_Enchantment_Type(20) As String
    Public intWeapon_Slot5_Enchantment_Amount(500) As Integer

    ' Any Weapon or Armor will have a Quality from -10 to +10 with 0 as being normal. 
    'When crafting the quality of the weapon or armor is determined by the users skill level, 
    'the resource used, and how many enchantments are trying to be added.
    Public intWeapon_Quality(20) As Integer

    ' The lowest amount of damage a weapon can deal before factoring in Armor
    Public intWeapon_Base_Min_Damage(500) As Integer ' (Calculation based on above effects)

    ' The highest amount of damage a weapon can deal before factoring in Armo
    Public intWeapon_Base_Max_Damage(500) As Integer ' (Calculation based on above effects)

    ' What the weapon can be sold for / half of buying price
    Public intWeapon_Selling_Price(500) As Integer ' (Calculation based on above effects)

    ' How heavy the weapon is, based on weapon type, resource used, and enchantments / effects carry weight and users speed
    Public intWeapon_Weight(500) As Integer

    ' Any other info that the user should know, used for story line aspects of the game
    Public strWeapon_Info(200) As String


    'So now lets sets there variables!


    'Used to put everything together at the end
    Public strFinalString As String



    Public Sub Set_Weapon_Variables()
        'Im going going to do one for each (except the integers), just as an example
        'A simple one enchantment dagger
        'This sub is where i would go thought and declare every variable of every string array. 
        strWeapon_Name_Prefix(1) = "Epic"
        strWeapon_Resource_Tyrpe(1) = "Iron"
        strWeapon_Type(1) = "Dagger"
        strWeapon_Name_Suffix(1) = "Of the Void"

        strWeapon_Slot2_Enchantment_Name(1) = "Bleeding Sorrow"
        StrWeapon_Slot2_Enchantment_Type(1) = "Causes Enemies to Bleed for "
        strWeapon_Info(1) = Nothing


        'Once I have all of the other variables of all the arrays declared here, 
        'we can mix and mash them together and create different weapons with the same code. 


        Extrapolate_Weapon_Date()

    End Sub

    'Now to use an item like the one we just defined, we need a number. 
    'its number but really its a string with numbers in it. 
    'this string would be 1,1,1,1,/1,1,10/,0,0,0/,0,0,0,/0,0,0,/0,0,0,/3,10,25,15,4,0 
    '(without the "/" , just used those to show you how it was broken up. 
    'first four numbers call the name arrays, the five sets of 3 are enchantments, 
    'and the last are the last bits of information listed above

    Public Sub Extrapolate_Weapon_Date()

        'For the sake of convenience ill go ahead and dim everything here, 
        'but pretend it was a public variable that was set to our weapon string 
        'on some mouse click event or something. 
        Dim SelectedWeaponDataString As String = "1,1,1,1,1,1,10,0,0,0,0,0,0,0,0,0,0,0,0,3,10,25,15,4,0"


        'These are going to be used at markers as we go though are Weapon Id Number
        Dim intStartLocationA As Integer = 1
        Dim intStartLocationB As Integer = 1

        'To keep this short we will only pick out the first four numbers, 
        'so the full name of the item. These Variables will hold the numbers that
        'Will be put into the correct Array to get the string out. 
        Dim namepart1 As Integer
        Dim namepart2 As Integer
        Dim namepart3 As Integer
        Dim namepart4 As Integer

        'Search the string and find the first ","
        intStartLocationB = InStr(intStartLocationA, SelectedWeaponDataString, ",")
        'Pick up the number between the start of the search and the search, 
        'for the length of the number we are looking for  = 'start of seach position' - 'the location of the next ","'
        namepart1 = Mid(SelectedWeaponDataString, intStartLocationA, (intStartLocationB - intStartLocationA))

        '+1 to the start of the next search position so we don't find the same "," that we just found
        intStartLocationB = intStartLocationB + 1
        intStartLocationA = InStr(intStartLocationB, SelectedWeaponDataString, ",")
        namepart2 = Mid(SelectedWeaponDataString, intStartLocationB, (intStartLocationA - intStartLocationB))

        intStartLocationA = intStartLocationA + 1
        intStartLocationB = InStr(intStartLocationA, SelectedWeaponDataString, ",")
        namepart3 = Mid(SelectedWeaponDataString, intStartLocationA, (intStartLocationB - intStartLocationA))

        intStartLocationB = intStartLocationB + 1
        intStartLocationA = InStr(intStartLocationB, SelectedWeaponDataString, ",")
        namepart4 = Mid(SelectedWeaponDataString, intStartLocationB, (intStartLocationA - intStartLocationB))


        'Here is where It all gets put into one string again
        strFinalString = strWeapon_Name_Prefix(namepart1) & " " & strWeapon_Resource_Tyrpe(namepart2) & " " & strWeapon_Type(namepart3) & " " & strWeapon_Name_Suffix(namepart4)

        'I set it to a button text but this is just a proof of concept
        frm4BrushForm.Button1.Text = strFinalString
    End Sub



End Module
Hope that makes sense... thanks for taking the time to read it :/
Reply With Quote
  #4  
Old 02-16-2013, 01:58 PM
AtmaWeapon's Avatar
AtmaWeaponRPG User Generated Item / Inventory System AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

First, play a lot of games in the genre you are imitating to get some ideas how others do it. The most prominent games with a very large item generation system are Diablo, Torchlight, and Borderlands. If you study their items (which many gamers have), you'll find they all follow the same pattern:
  • All items start as some basic item with a narrow range of base stats.
  • Augmentations are applied one at a time, and afterwards all augmentations are applied.
For example, suppose you find a "PPZ9 Rolling Gamble" sniper rifle in Borderlands 2. The "PPZ" indicates it has had "body5" added, applying +20% damage, +50% rate of fire, -20% recoil, and an additional tech level. "9" indicates no special stock and magazine 3: a reduced-capacity magazine with a +21% damage and -15% reload speed bonus in addition to +3 to tech level. The barrel and scope are not distinguishable from the model name and would have to be deduced from visual identification. "Heavy" is an identifier that can indicate the "rolling" accessory, which grants a manual-action sniper rifle a 100% reload speed bonus. "Gamble" is a sniper rifle type with +50% critical hit damage but accuracy decreased 10-12% compared to other sniper rifles; it can only be applied to rifles with a tech level of 5, so this is an indicator the stock and/or barrel is one that increases tech level.

Diablo is a little more random; you apply runes that can give various titles to items. Generating the title is sort of more difficult than setting the statistics properly, but is easy if you focus on just prefixes. For example, if one rune can make your "steel sword" a "steel sword of bleeding", what happens if you also apply a rune that would make it "steel sword of seek flesh"? It's much easier to generate a name like "keen sharpened steel sword" from two runes, or use rules like "suffixed runes are more powerful and you can only apply one at a time".

Now, how to do it? I've attached an example. It's not written the /best/ way, but it works. It's your job to learn from it and figure out what your program needs.

My example starts with an ItemData class. This is something basic, like "sword" or "axe". It has an attack, defense, and "augment slots" I'll explain later.

Next is MaterialData. This represents what items can be made of, like "steel" or "iron". These have attack, defense, and augment slot "modifiers", which can either be a flat change like +10 or a percentage like -10%.

Finally, augments. These are like Diablo's runes. They have an attack and defense modifier. An item can have a number of these applied up to the total number of slots defined by the ItemData and any material modifiers.

These are all combined to make a GeneratedItem. To make one of these, I get a random item, random material, and random number of augments and add them. Each time part of the GeneratedItem changes, I follow these steps:
  • Generate a new attack based on the item's base attack, material attack modifier, and all augment attack modifiers.
  • Generate a new defense based on the item's base defense, material defense modifier, and all augment defense modifiers.
  • Update the list of augments if the item's slots or material augment slot modifiers have changed.
  • Generate a name of the form "<augmentPrefix> <materialName> <itemName>", adding each augment prefix.
There's quite a few problems with this example, but you can sort them out as you go. This is meant to give you an idea of how to use the notion of a "base" statistic and a series of modifiers to create a real item without having to know the number of total combinations in advance.
Attached Files
File Type: zip example.zip (11.1 KB, 7 views)
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #5  
Old 02-16-2013, 02:46 PM
Under Study Under Study is offline
Regular
 
Join Date: Jul 2008
Posts: 83
Default

Thank you for the example Atma! Like everything else, there is a lot more to classes than I knew. Not even sure how this is reading the text file like it is. Looks like I will be on MSDN for the rest of my weekend. Thanks for the help and push in the right direct.

Edit*
_____________________
Ive been trying to wrap my head around this for the past several house and still cant seem to have it add up. The code you gave makes sense for any time I would need to randomly create an Item, but If i want to create a specific item using a similar class system setup my head starts exploding. haha... Guess my nose is going back in the books.

2nd Edit*
____________________
Ok, so when I look t something for so long I tend to get set on looking at it only one way... so idk if I totally messed this up or what, but this is what i got when done with classes.


My Class like before but with only the first 4 variables but more options
Code:
Public Class WeaponData

    Public PrefixEpic As String = "Epic"
    Public PrefixLegendary As String = "Legendary"
    Public PrefixBloody As String = "Bloody"
    Public PrefixDangerous As String = "Dangerous"
    Public PrefixVicious As String = "Vicious"

    Public ResourcesIron As String = "Iron"
    Public ResourcesSliver As String = "Sliver"
    Public ResourcesGold As String = "Gold"
    Public ResourcesTitanium As String = "Titanium"
    Public ResourcesMithril As String = "Mithril"
    Public ResourcesYellowPine As String = "Yellow Pine"
    Public ResourcesBlackWalnet As String = "Black Walnut"
    Public ResourcesWhiteOak As String = "White Oak"
    Public ResourcesGreyMaple As String = "Gray Maple"
    Public ResourcesPurpleHickory As String = "Purple Hickory"

    Public TypeDagger As String = "Dagger"
    Public TypeAxe As String = "Axe"
    Public TypeShortSword As String = "Short Sword "
    Public TypeMace As String = "Mace"
    Public TypeLongSword As String = "Long Sword"
    Public TypeBattleAxe As String = "Battle Axe"
    Public TypeWarHammer As String = "War Hammer"

    Public TypeStaff As String = "Staff"
    Public TypeWant As String = "Wand"
    Public TypeRelic As String = "Relic"
    Public TypeCrossBow As String = "Cross Bow"
    Public TypeShortBow As String = "Short Bow"
    Public TypeLongBow As String = "Long Bow"
    Public TypeCompoundBow As String = "Compound Bow"
    Public TypeTrowingKnives As String = "Trowing Knives"


    Public SuffixOfFire As String = "Of Fire"
    Public SuffixOfLice As String = "Of Ice"
    Public SuffixOfShock As String = "Of Shock"
    Public SuffixOfAcid As String = "Of Acid"
    Public SuffixOfPower As String = "Of Power"
    Public SuffixOfPunishment As String = "Of Punishment"
    Public SuffixOfDeath As String = "Of Death"
    Public SuffixOfLife As String = "Of Life"
    Public SuffixOfTheVoid As String = "Of the Void"


End Class
and the same idea as before, a button that sets its text to the name on the form as a proof of concept

Code:
Public Class Form1
    Public Dagger As String
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


        Dim Info As New WeaponData


        Dagger = Info.PrefixBloody & Info.ResourcesIron & Info.TypeDagger & Info.SuffixOfDeath


    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Button1.Text = Dagger
    End Sub
End Class

my only problem with doing it this way is this part.
Quote:
Dagger = Info.PrefixBloody & Info.ResourcesIron & Info.TypeDagger & Info.SuffixOfDeath
The Array way I had about i could easy manipulate the variable by changing one integer on the integer
Code:
 SelectedWeaponDataString = "1,1,1,1,1,1,10,0,0,0,0,0,0,0,0,0,0,0,0,3,10,25,15,4,0"
Now the Class away does seem much simpler but I dont think I can do it in the same way... right?

Last edited by Under Study; 02-16-2013 at 09:39 PM.
Reply With Quote
  #6  
Old 02-17-2013, 08:54 AM
AtmaWeapon's Avatar
AtmaWeaponRPG User Generated Item / Inventory System AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

What if the Armory class were written so that you could get a particular item, instead of a random one? You could make a particular item like this:
Code:
Dim sword = armory.GetItem("sword")
Dim iron = armory.GetMaterial("iron")
Dim adamant = armory.GetAugment("adamant")

Dim specificSword = New GeneratedItem()
specificSword.SetItem(sword)
specificSword.SetMaterial(iron)
specificSword.SetAugment(0, adamant)
Working with comma-separated strings to represent statistics is very complex. Working with arrays is slightly less complex. Working with classes is semantically easy. Don't think of classes as this big intimidating subject. Using classes instead of loose collections of variables is the difference between saying "This is 3, 0, 0, 1, 2, 3" and "This is a fresh orange that hasn't been peeled yet."

There's nothing to it, once you get over the silly notion that there's a "right" way. There's only ways that are easier and harder than the others. It's like drawing a picture, you think about it, draw some shapes, then decide if it'd good or not. If not, you throw it away and try again. When making classes, you think, "What is a weapon?" and add properties and methods you think will be useful. Over time, you ask yourself, "Are things hard?" and if so, you try to figure out how you can change them to make them easy.

So try. Get your hands dirty. Make mistakes. It's how you learn.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.

Last edited by AtmaWeapon; 02-18-2013 at 08:29 AM.
Reply With Quote
  #7  
Old 02-20-2013, 11:39 AM
Under Study Under Study is offline
Regular
 
Join Date: Jul 2008
Posts: 83
Default

Ok, so things have really started clicking and all is working well except for one thing. I cant use an array to set up a new class. Right? Because this...

Code:
Public CraftedWeapons() as new WeaponsClass
... Doesnt work.

In every way Ive tried this I can't get it to save my new weapon info to a string array. The idea behind it that each weapon created would get saved somewhere, and a simple array that i could call with an integer seems the best. Ill keep at it, just wasn't sure if it was even possible with classes. Right now each time I run the code it overwrites the variables of the one before it.


*Edit
_________________

Let me try to explain a bit better. The user should be able to create and save as many weapons as they want. Right now, im just struggling with the "saving" part, as it, getting my class variables to other variables so they are not rewritten the next time the user creates a weapon.


*Edit 2
_________________

Turns out im just dumb and messed something small up, although I would still like to know what you guys think.

Last edited by Under Study; 02-20-2013 at 11:53 AM.
Reply With Quote
  #8  
Old 02-20-2013, 12:15 PM
passel's Avatar
passelRPG User Generated Item / Inventory System passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,028
Default

Rather than an array, I would thing using a List would be simpler.
You can use an index to access the list, like an array, but you would simply add instances of your WeaponsClass as necessary, and the list would take care of the chores normally associated with using an array, such as increasing the size of the array, while maintaining the contents etc.
In any case, you would drop the "new" when defining your array.
You would use "new" when creating an instance of the class when assigned to your array.
Something along these lines.
Code:
Public CraftedWeapons(50) as WeaponsClass

'later when a weapon has been defined (assume weaponIndex points to the next available "slot")


CraftedWeapons(weaponIndex) = new WeaponsClass()
'initialize your data here, or perhaps pass a class to your weaponsClass as a parameter with all the preset data.
With CraftedWeapons(weaponIndex)
  .this = something
  .that = something else
  .etc = etc
End With

weaponIndex +=1  'Point to the next empty slot
If weaponIndex => CraftedWeapons.Length Then
  'we need to resize the array to hold more items
End If
But if you used a List, you wouldn't need to worry about allocating array space and resizing.
Code:
  Dim WeaponList As New List(Of WeaponClass)


'later in the code to add another weapon class you could do something like
  WeaponList.Add(New WeaponClass)
  With WeaponList.Last
    .this = something
    .that = something else
    .etc = etc
  End With

You could also access by index, if you're keeping track of that somehow.
  With WeaponList(0)
    .this = something
    .that = something else
    .etc = etc
  End With

'or
    WeaponList(0).this = something
    WeaponList(0).that = something else
    WeaponList(0).etc = etc
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #9  
Old 02-20-2013, 03:53 PM
surfR2911 surfR2911 is offline
Contributor
 
Join Date: Oct 2009
Posts: 719
Default Using VB.Net data structures other than arrays..

Quote:
Originally Posted by passel
Rather than an array, I would thing using a List would be simpler.
I agree with passel.
If only someone had hinted at this before..
Quote:
Originally Posted by surfR2911 (from post #2)
While arrays are "old school", have been around for a while (like in VB6), and still work in VB.Net,
there are other ways of storing bits of information a regularized way.
Of course there many storage collections in the System.Collections Namespace..
Oh wait..I did.

Maybe I should have provided a direct link to the MSDN List(Of T) Class page (under the System.Collections.Generic section),
but I then again I did a provide a link to the stupid question thread that explores List(of T) coding.

To passel, thanks for joining this thread and (as always), providing a great code example.
Hopefully Under Study appreciates your efforts to guide him to more of a "VB.Net way" of doing things.
Reply With Quote
  #10  
Old 02-20-2013, 06:37 PM
AtmaWeapon's Avatar
AtmaWeaponRPG User Generated Item / Inventory System AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

Also your syntax is wrong for arrays. The "New" keyword is for calling constructors to create single objects. The appropriate array syntax is:
Code:
<specifier> <name>[([bound])] As <dataType>[([bound])]

* specifier := Dim | Public | Private | Protected | Friend
* bound is an integer that indicates the upper bound of the array
* dataType must be a valid data type
* The () can be by the name or the data type.
* The bounds are optional, but the variable is Nothing until ReDim is used if
    it is not specified.
That's the stuffy way; here's an example:
Code:
Dim strings() As String
Dim objects As WeaponClass(3)
The first is an uninitialized array of Strings; you have to use ReDim to give it a size. The second is a 4-element array of WeaponClass, initialized to Nothing in each element.

I too echo the suggestions to use a List(Of T) instead. Arrays are most useful when you know the number of items will never change. This is rare.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
RPG User Generated Item / Inventory System
RPG User Generated Item / Inventory System
RPG User Generated Item / Inventory System RPG User Generated Item / Inventory System
RPG User Generated Item / Inventory System
RPG User Generated Item / Inventory System
RPG User Generated Item / Inventory System RPG User Generated Item / Inventory System RPG User Generated Item / Inventory System RPG User Generated Item / Inventory System RPG User Generated Item / Inventory System RPG User Generated Item / Inventory System RPG User Generated Item / Inventory System
RPG User Generated Item / Inventory System
RPG User Generated Item / Inventory System
 
RPG User Generated Item / Inventory System
RPG User Generated Item / Inventory System
 
-->