04. juni 2004 - 18:09Der er
4 kommentarer og 1 løsning
Split op og replace
Hejsa... Er ved at lave et program der skal kunne splitte en txt streng op, og erstatte hver enkelt tegn med andet specifikt tegn... Er der nogen der kan vise hvordan det gøres, tak ! :)
Private Sub Command1_Click() Dim iBuffer As Integer Dim Result As String
For iBuffer = 1 To Len(Text1.Text) Select Case Mid$(Text1.Text, iBuffer, 1) Case Is = "a" Result = Result & "4" Case Is = "b" Result = Result & "8" Case Is = "c" Result = Result & "(" Case Is = "d" Result = Result & "(" Case Is = "e" Result = Result & "3" Case Is = "f" Result = Result & "(" Case Is = "g" Result = Result & "6" Case Is = "h" Result = Result & "|-|" Case Is = "i" Result = Result & "1" Case Is = "j" Result = Result & "9" Case Is = "k" Result = Result & "|<" Case Is = "l" Result = Result & "|_" Case Is = "m" Result = Result & "/\/\" Case Is = "n" Result = Result & "/\/" Case Is = "o" Result = Result & "0" Case Is = "p" Result = Result & "|o" Case Is = "q" Result = Result & "o|" Case Is = "r" Result = Result & "r" Case Is = "s" Result = Result & "Z" Case Is = "t" Result = Result & "7" Case Is = "u" Result = Result & "|_|" Case Is = "v" Result = Result & "\/" Case Is = "w" Result = Result & "\/\/" Case Is = "x" Result = Result & "><" Case Is = "y" Result = Result & "y" Case Is = "z" Result = Result & "%" Case Is = " " Result = Result & " " Case Is = "." Result = Result & "." End Select Next iBuffer Text2.Text = Result End Sub
Replace virker fint såfremt du ikke bruger VB 4.0-, jeg vil klart anbefale dig at bruge ASCII værdier og et loop i stedet for din lange case statement. For at se ascii værdierne kan du gøre sådan her:
Smid en listbox på din form, og skriv det her i form load:
For I = 0 To 255 List1.AddItem I & " " & Chr(I) Next
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.