Question Change one character to multiple characters

vis15

New member
Joined
Jun 4, 2009
Messages
1
Programming Experience
1-3
Hi, I'm Vis15. I am trying to create this simple function that changes one character to multiple characters multiple times. For example if I have a string "abcde" I want the end result to be something like:
aXcde
aYcde
aZcde
abXde
abYde
abZde
aXXde
aXYde
aXZde
aYXde
aYYde
...
Here is what I got so far:

VB.NET:
    Public Function Rotate(ByVal strString As String) As String
        Dim i As Integer = 0
        Dim chr As String = ""
        Dim tmp As String = ""
        Dim j As Integer = 0
        Dim jchr As Boolean = False
        Dim tmp2 As String = ""
        Dim tmp3 As String = ""
        Dim chrcnt As Integer = 0
        Dim k As Integer = 1

        For k = 1 To 3
            For j = 1 To 5
                tmp2 = ""
                For i = 1 To Len(strString)
                    chr = Mid(strString, i, 1)
                    tmp = chr
                    If jchr = False Then
                        tmp = ChangeSym(chr, j) 'Just changes one symbol for another
                    End If
                    If chr = tmp Then 'chr is not a symbol 
                        tmp2 = tmp2 & chr
                    Else
                        tmp2 = tmp2 & tmp
                        jchr = True
                    End If
                Next
                jchr = False
                tmp3 = tmp3 & vbCrLf & tmp2
            Next
            chrcnt = chrcnt + 1
        Next

        Return tmp3
    End Function
 
I'm not getting what you are trying to do. Are you trying to replace all the 'b's?
 

Latest posts

Back
Top