Récupérer une partie d'un mot

Theadri1900 - 3 févr. 2013 à 17:59
 Theadri1900 - 3 févr. 2013 à 19:00
Bonjour, je vous contact car j'ai un petit problème :
Je suis en train de créer un logiciel qui permet de lire un certain type de fichier dans un jeu vidéo.
Je récupère donc le flux de caractère et le compare a des données pour déterminer un paramètre dans mon logiciel.
par exemple :

If lecture = "generate-structure=false" then
combobox13.text = "Non"

Mais j'ai un problème quand c'est quelque chose du genre :

Name-of-world=Monmonde

j'aimerait que je puisse découper cette chaine de caractère par le = et donc dans un premier temps dire ok, c'est le paramètre name-of-word puis je vous que c'est monmonde.

Connaisez vous ce code ??

2 réponses

Utilisateur anonyme
3 févr. 2013 à 18:52
Bonjour,

Dans l'aide:

String, Classe
string.index0f, méthode
string.substring, méthode
string.split, méthode

Je suis persuadé qu'il y a même des exemples.

dim texte as string="generate-structure=false"
dim place as integer = texte.indexof("=")
dim agauche as string = texte.substing(0,place-1)
dim adroite as string = texte.substring(place +1, texte.length-1)


ou bedon passer par string.split()
0
Benn, tu verrais comment l'intégrer au code :

            Dim lecture As New System.IO.StreamReader(OpenFileDialog1.FileName)
            Dim lecture2 As String
            Do While lecture.EndOfStream = False

                lecture2 = (lecture.ReadLine)
                If lecture2 = "allow-nether=true" Then
                    ComboBox1.Text = "Oui"
                ElseIf lecture2 = "allow-nether=false" Then
                    ComboBox1.Text = "Non"
                ElseIf lecture2 = "allow-flight=true" Then
                    ComboBox2.Text = "Oui"
                ElseIf lecture2 = "allow-flight=false" Then
                    ComboBox2.Text = "Non"
                ElseIf lecture2 = "level-type=DEFAULT" Then
                    ComboBox3.Text = "Normal"
                ElseIf lecture2 = "level-type=FLAT" Then
                    ComboBox3.Text = "Plat"
                ElseIf lecture2 = "level-type=LARGEBIOMES" Then
                    ComboBox3.Text = "Larges Biomes"
                ElseIf lecture2 = "spawn-npcs=true" Then
                    ComboBox4.Text = "Oui"
                ElseIf lecture2 = "spawn-npcs=false" Then
                    ComboBox4.Text = "Non"
                ElseIf lecture2 = "white-list=true" Then
                    ComboBox5.Text = "Oui"
                ElseIf lecture2 = "white-list=false" Then
                    ComboBox5.Text = "Non"
                ElseIf lecture2 = "spawn-animals=true" Then
                    ComboBox6.Text = "Oui"
                ElseIf lecture2 = "spawn-animals=false" Then
                    ComboBox6.Text = "Non"
                ElseIf lecture2 = "hardcore=true" Then
                    ComboBox12.Text = "Oui"
                ElseIf lecture2 = "hardcore=false" Then
                    ComboBox12.Text = "Non"
                ElseIf lecture2 = "online-mode=false" Then
                    ComboBox7.Text = "Oui"
                ElseIf lecture2 = "online-mode=true" Then
                    ComboBox8.Text = "Non"
                ElseIf lecture2 = "pvp=true" Then
                    ComboBox8.Text = "Oui"
                ElseIf lecture2 = "pvp=false" Then
                    ComboBox8.Text = "Non"
                ElseIf lecture2 = "difficulty=0" Then
                    ComboBox9.Text = "Paisible"
                ElseIf lecture2 = "difficulty=1" Then
                    ComboBox9.Text = "Facile"
                ElseIf lecture2 = "difficulty=2" Then
                    ComboBox9.Text = "Normal"
                ElseIf lecture2 = "difficulty=3" Then
                    ComboBox9.Text = "Difficile"
                ElseIf lecture2 = "gamemode=0" Then
                    ComboBox10.Text = "Aventure"
                ElseIf lecture2 = "gamemode=1" Then
                    ComboBox10.Text = "Survie"
                ElseIf lecture2 = "gamemode=2" Then
                    ComboBox10.Text = "Créatif"
                ElseIf lecture2 = "spawn-monsters=true" Then
                    ComboBox11.Text = "Oui"
                ElseIf lecture2 = "spawn-monsters=false" Then
                    ComboBox11.Text = "Non"
                ElseIf lecture2 = "generate-structures=true" Then
                    ComboBox13.Text = "Oui"
                ElseIf lecture2 = "generate-structures=false" Then
                    ComboBox13.Text = "Non"
                End If

            Loop


??
0
Rejoignez-nous