Edit a text string

Pablo56

New member
Joined
Feb 26, 2022
Messages
4
Programming Experience
Beginner
Hi. This is more for interest as a beginer. I used to edit strings in old fashend VB6. This simply involved changing a charecter in a string. E.G.

MySting[4] = "Z"

Can someone tell me how to get a string like "ABCDEFG" and swap B and E over. Very usefull when using information posted in a link. A kind of encription like.

Sorry if I am being a bit of a nuisence for asking something so basic.
 
.NET Strings are immutable, meaning that you cannot modify one once its created. You would need to create a new String object containing the desired modification. You could use the existing Mid statement, e.g.
VB.NET:
Dim myString = "ABCDEFG"

Mid(myString, 4, 1) = "Z"
or you could write your own method or just do it in place if it's a one-off.
 
Hi. I am trying to call a subrouten and return a value to string. I have a rich text box with the text.

Private Sub BtnOriginal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEncript.Click
Dim temp As String
temp = txtOriginal.Text
temp = RRL(temp)
End Sub

Private Sub RRL(ByRef MyStartString As String)
MyStartString = txtOriginal.Text.ToUpper
End Sub
 
Last edited:
That code makes little sense as it is. It is functionally equivalent to this:
VB.NET:
Private Sub BtnOriginal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEncript.Click
    Dim temp = txtOriginal.Text.ToUpper()
End Sub
It does nothing useful.
 
Back
Top