English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Dim myArray ( ) As String = {“Gun”, “Bullets”, “Knife”, “Holster”}

or when it is a un-sized array is it Dim myOtherArray ( ) As String = {“Gun”, “Bullets”, “Knife”, “Holster”}

or is that only if I have previously declared an array?

2006-09-02 11:52:08 · 1 answers · asked by Anonymous in Computers & Internet Programming & Design

1 answers

I'm not quite sure what you're asking, but here goes my best shot :)

Both of your array declarations are correct, and can be added to at any time.

Let's take your first array as an example:

For now we have:

myArray(0) = "Gun"
myArray(1)="Bullets"
myArray(2) = "Knife"
myArray(3) = "Holster"

You can at any time add to this array by simply stating something like this:

myArray(4) = "Banana"

So, if this were say...a characters inventory in a game you were creating:

Dim Inventory() As String = {"Gun","Bullets","Knife","Holster"}

If myCharacter.Location = worldItem.Location Then
dim inventoryCount as Integer
inventoryCount = Inventory().Count
inventoryCount++
Inventory(inventoryCount) = worldItem.Name("Banana")
End If

The above code has several assumptions, such as you having already declared character and world item information, but in a nutshell, it states "If the characters steps on top of this item, add it to his inventory in a new slot"

Hope that's what you were looking for :)

2006-09-02 12:01:00 · answer #1 · answered by addtheninth 2 · 0 0

fedest.com, questions and answers