Hallo Leute!
Ich hänge gerade an einem Projekt, bei dem ich gerne eizelne Zeichen aus einem Text, der in einer Textbox geschrieben steht, mit anderen Zeichen ersetzen möchte, die in einer Textdatei gespeichert sind.
Hier schonmal ein Ausschnitt aus dem Replace-Prozedere:
Spoiler anzeigen
Hier nochmal die ReadLine-Funktion:
Spoiler anzeigen
Wenn ich jedoch das Programm debugge kommt folgende Fehlermeldung:
Da ich mich noch als Anfänger in Visual Basic ansehe, bin ich mir nicht sicher, aber bedeutet Boolean nicht eine Aussage wie "true", oder "false"?
Kann mir bitte jemand erklären, was ich tun soll, damit dies richtig funktioniert?
Danke im Vorraus!
Ich hänge gerade an einem Projekt, bei dem ich gerne eizelne Zeichen aus einem Text, der in einer Textbox geschrieben steht, mit anderen Zeichen ersetzen möchte, die in einer Textdatei gespeichert sind.
Hier schonmal ein Ausschnitt aus dem Replace-Prozedere:
VB.NET-Quellcode
- TextToCrypt.Text = texttocrypt.text.Replace("z", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 98)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("y", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 97)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("x", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 96)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("w", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 95)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("v", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 94)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("u", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 93)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("t", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 92)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("s", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 91)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("r", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 90)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("q", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 89)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("p", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 88)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("o", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 87)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("n", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 86)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("m", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 85)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("l", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 84)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("k", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 83)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("j", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 82)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("i", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 81)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("h", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 80)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("g", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 79)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("f", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 78)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("e", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 77)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("d", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 76)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("c", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 75)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("b", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 74)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("a", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 73)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("0", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 72)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("9", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 71)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("8", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 70)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("7", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 69)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("6", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 68)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("5", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 67)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("4", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 66)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("3", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 65)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("2", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 64)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("1", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 63)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("Z", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 62)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("Y", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 61)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("X", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 60)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("W", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 59)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("V", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 58)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("U", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 57)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("T", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 56)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("S", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 55)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("R", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 54)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("Q", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 53)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("P", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 52)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("O", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 51)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("N", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 50)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("M", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 49)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("L", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 48)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("K", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 47)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("J", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 46)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("I", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 45)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("H", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 44)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("G", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 43)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("F", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 42)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("E", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 41)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("D", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 40)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("C", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 39)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("B", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 38)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("A", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 37)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("|", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 36)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("_", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 35)) & _
- TextToCrypt.Text = texttocrypt.text.Replace(":", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 34)) & _
- TextToCrypt.Text = texttocrypt.text.Replace(";", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 33)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("<", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 32)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("~", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 31)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("¨", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 30)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("´", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 29)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("\", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 28)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("}", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 27)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("]", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 26)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("[", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 25)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("{", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 24)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("€", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 23)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("$", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 22)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("£", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 21)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("@", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 20)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("§", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 19)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("-", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 18)) & _
- TextToCrypt.Text = texttocrypt.text.Replace(".", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 17)) & _
- TextToCrypt.Text = texttocrypt.text.Replace(",", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 16)) & _
- TextToCrypt.Text = texttocrypt.text.Replace(">", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 15)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("*", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 14)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("^", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 13)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("`", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 12)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("?", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 11)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("=", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 10)) & _
- TextToCrypt.Text = texttocrypt.text.Replace(")", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 9)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("(", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 8)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("/", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 7)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("&", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 6)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("%", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 5)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("¤", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 4)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("#", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 3)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("!", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 2)) & _
- TextToCrypt.Text = texttocrypt.text.Replace("½", ReadLine(Path.GetDirectoryName(Application.ExecutablePath) + "\Text.txt", 1))
Hier nochmal die ReadLine-Funktion:
VB.NET-Quellcode
- Public Function ReadLine(ByVal filename As String, _
- ByVal line As Integer) As String
- Try
- Dim lines As String() = My.Computer.FileSystem.ReadAllText( _
- filename, System.Text.Encoding.Default).Split(vbCrLf)
- If line > 0 Then
- ' n-te Zeile vom Anfang der Textdatei
- Return lines(line - 1)
- ElseIf line < 0 Then
- ' n-te Zeile beginnend am Ende der Textdatei
- Return lines(lines.Length + line - 1)
- Else
- ' ungültige Zeilennummer
- Return ""
- End If
- Catch ex As Exception
- Return ""
- End Try
- End Function
Wenn ich jedoch das Programm debugge kommt folgende Fehlermeldung:
Da ich mich noch als Anfänger in Visual Basic ansehe, bin ich mir nicht sicher, aber bedeutet Boolean nicht eine Aussage wie "true", oder "false"?
Kann mir bitte jemand erklären, was ich tun soll, damit dies richtig funktioniert?
Danke im Vorraus!