IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

[VB.NET] Tableau "index was outside of bound array"


Sujet :

VB.NET

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    62
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 62
    Points : 53
    Points
    53
    Par défaut [VB.NET] Tableau "index was outside of bound array"
    Salut tout le monde voila j'ai encore un petit probleme ^^
    La fonction suivante me permet d'extraire l'index,le nom,les kill,les temps de connection de joueur d'un serveur.Sa marche bien en affichant une par une les infos avec des message box mais je n'arrive pas a les mettre dans un tableau pour les retourner ensuite :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    Function ParsePlayer(ByVal receivedata() As Byte)
            Dim index As Integer = 6
            Dim phase As Integer = 1
            Dim decoder As New ASCIIEncoding
            Dim TimesBytes(3) As Byte
            Dim PlayerInfo(64) As Integer
            Dim PlayerInfoIndex As Integer = 0
     
            Try
                For index = 6 To receivedata.Length - 1
                    If phase = 1 Then
                        MessageBox.Show(Convert.ToInt32(receivedata(index)))
                        phase = 2
                        index = index + 1
                    End If
                    If phase = 2 Then
                        MessageBox.Show(decoder.GetString(receivedata, index, getNextIndex(receivedata, index) - index))
                        phase = 3
                        index = index + getNextIndex(receivedata, index) - index
                    End If
                    If phase = 3 Then
                        MessageBox.Show(Convert.ToUInt32(receivedata(index)))
                        phase = 4
                        index = index + 1
                    End If
                    If phase = 4 Then
                        Array.Copy(receivedata, index + 3, TimesBytes, 0, 4)
                        Dim times As New TimeSpan(0, 0, BitConverter.ToSingle(TimesBytes, 0))
                        MessageBox.Show(times.Hours & "h " & times.Minutes & "min " & times.Seconds & "sec")
                        phase = 1
                        index = index + 6
                    End If
                Next
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
     
            Return Nothing
        End Function
    J'ai essayer essayer avec ce type de code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    dim playerinfo(64) as string
    dim playerinfoindex as integer = 0
     
     If phase = 1 Then
                        playerinfo(playerinfoindex) = Convert.ToInt32(receivedata(index))
    playerinfoindex += 1
                        phase = 2
                        index = index + 1
                    End If
    Mais sa ne marche pas et maffiche un message d'erreur "index was outside of bound array".

    Merci @+

  2. #2
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    62
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 62
    Points : 53
    Points
    53
    Par défaut
    Je viens de regler le probleme en mettant receivedata.Length - 1

    Bye

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Débutant] index was outside of the bounds of the array
    Par labib23dz dans le forum C#
    Réponses: 1
    Dernier message: 09/04/2012, 12h53
  2. Réponses: 0
    Dernier message: 25/01/2012, 15h34
  3. ERREUR : Index was outside the bounds of the array
    Par maxwel56 dans le forum Linq
    Réponses: 1
    Dernier message: 06/02/2010, 10h40
  4. Index was outside the bounds of the array
    Par richton95 dans le forum Windows Presentation Foundation
    Réponses: 16
    Dernier message: 01/09/2009, 16h07

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo