I need some help with the following code please. I am new to programming so any support is appreciated.
The code below is meant to replace the letters of any given message. The letters of the variable message should be replaced by letters from the variable random_alphabet. This can be done based on their index (which is why a For loop is needed).
You can tell that the Replace() function in the For loop does not do what it is meant to do. Any ideas of how to fix it please? Or a suggestion of using a different function?
Thank you.
The code below is meant to replace the letters of any given message. The letters of the variable message should be replaced by letters from the variable random_alphabet. This can be done based on their index (which is why a For loop is needed).
Code:
Dim message As String = "hello"
Dim alphabet As String = "abcdefghijklmnopqrstuvwxyz"
Dim random_alphabet As String = "kxgtlmpqbwcnderfahjusviyoz"
Dim change As String
For i = 0 To message.Length - 1
change = Replace(message, message(i), random_alphabet(i))
Console.WriteLine(change)
Next
You can tell that the Replace() function in the For loop does not do what it is meant to do. Any ideas of how to fix it please? Or a suggestion of using a different function?
Thank you.