Reputation: 1
Here is my code (everything is pre-declared for use in the entire form's class):
Private Sub Pokedex_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
IntPokemonCounter = 0
Dim fileReader As System.IO.StreamReader
fileReader = My.Computer.FileSystem.OpenTextFileReader("TotalPokemonNames.txt")
While (IntPokemonCounter < 51)
PokémonName(IntPokemonCounter) = fileReader.ReadLine()
listPokemon.Items.Add(PokémonName(IntPokemonCounter))
ComboBox1.Items.Add(PokémonNumber(IntPokemonCounter) + "" + PokémonName(IntPokemonCounter))
'MsgBox("The " & IntPokemonCounter + 1 & "th pokemon is " & PokémonName(IntPokemonCounter))
IntPokemonCounter += 1
End While
IntPokemonCounter = 0
While (IntPokemonCounter < 51)
PokémonNumber(IntPokemonCounter) = IntPokemonCounter + 1
If PokémonNumber.Length = 1 Then
PokémonNumber(IntPokemonCounter) = "00" + (IntPokemonCounter + 1)
ElseIf PokémonNumber.Length = 2 Then
PokémonNumber(IntPokemonCounter) = "0" + (IntPokemonCounter + 1)
End If
IntPokemonCounter += 1
End While
IntPokemonCounter = 0
While (IntPokemonCounter < 51)
PokemonPics(IntPokemonCounter < 51) = My.Resources.(PokémonName(IntPokemonCounter) &".png")
listPokemon.Items.Add(PokémonNumber(IntPokemonCounter) + PokémonName(IntPokemonCounter))
'MsgBox("The " & IntPokemonCounter + 1 & "th pokemon is " & PokémonName(IntPokemonCounter))
IntPokemonCounter += 1
End While
End Sub
The problem I'm having is not being able to choose a picture out of the names loaded from the .txt file. The pictures are loaded into resources and I dont want to make 151 if statements for each Pokemon, this is mainly based off of big data. When I place it like this, it says "Identifier expected", instead of accepting the variable used in this line
PokemonPics(IntPokemonCounter < 51) = My.Resources.(PokémonName(IntPokemonCounter) &".png")
Originally I was going to load the picture directly to the picturebox but I hoped the array might fix the problem, it did not. This is for my Final Project, I am re-creating pokemon Red in Visual basic 2008 express edition. Thank you so much for any help provided.
Upvotes: 0
Views: 546