Les machines ne font pas d'erreurs
Heureusement nous sommes humains
' String to search in. Dim SearchString As String = "XXpXXpXXPXXP" ' Search for "P". Dim SearchChar As String = "P" Dim TestPos As Integer ' A textual comparison starting at position 4. Returns 6. TestPos = InStr(4, SearchString, SearchChar, CompareMethod.Text) ' A binary comparison starting at position 1. Returns 9. TestPos = InStr(1, SearchString, SearchChar, CompareMethod.Binary) ' If Option Compare is not set, or set to Binary, return 9. ' If Option Compare is set to Text, returns 3. TestPos = InStr(SearchString, SearchChar) ' Returns 0. TestPos = InStr(1, SearchString, "W")
Les machines ne font pas d'erreurs
Heureusement nous sommes humains
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDim SourceFile As New StreamReader("c:\\test.txt") Dim ligne As String While ligne = SourceFile.readline if ligne.indexOf("le texte que je cherche") <> -1 then listbox.text = "le texte que je cherche" end If end while SourceFile.close
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click If My.Computer.FileSystem.ReadAllText("c:\s.txt", System.Text.Encoding.ASCII).Contains("bonjour") Then MessageBox.Show("'bonjour' est bien présent dans le fichier") Else MessageBox.Show("'bonjour' n'a pas été trouvé dans le fichier") End If End Sub
MessageBox.Show(CountOccurrences(My.Computer.FileSystem.ReadAllText("c:\test.txt", System.Text.Encoding.ASCII), "bon").ToString)
Do ligne = SourceFile.ReadLine() If ligne <> "" Then ("sonia") If trouve = True Then Do ligne = SourceFile.ReadLine() If ligne <> "" Then If ligne.Contains("sonia") then _ n += 1 End If Loop Until ligne Is Nothing
Catch ex As Exception MsgBox("Une erreur est survenue au cours de l'accès en lecture du fichier de configuration." & vbCrLf & vbCrLf & _ "Veuillez vérifier l'emplacement : erreur lors de l'ouverture du fichier." & VbCrLf & VbCrLf & _ "Détails de l'erreur: " & Ex.Message) End Try