Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

How would I avoid that error? It happens on this line of code:

           txtWord.Text = Replace$(txtWord.Text.Chars(I), txtWord.Text.Chars(I), "*")

 

I've also tried

           txtWord.Text = Replace$(txtWord.Text, txtWord.Text.Chars(I), "*")

but I get the same error.

Any help?

Posted

Actually, I do need help.

I get that error on these lines instead:

       Dim SB As New System.Text.StringBuilder(CurWord)
       Dim SBW As New System.Text.StringBuilder(txtWord.Text)
       Dim SBG As New StringBuilder(txtGuess.Text)
       For I = 0 To SB.Length ' Here
           If SB(I) = SBG(I) Then ' Here
               txtWord.Text = Replace(SBW(I), SB(I), SBG(I), 1, I) ' and here
           End If
       Next

 

How do I stop that? Or at least, how do you replace individual characters?

Posted

Is there a way to replace individual characters

e.g

Dim This As String = "ThisThis"
Dim That As String = "ThatThat"
txtWord.Text = This & That
For I = 0 To txtWord.Text - 1
txtWord.Text = Replace(txtWord.Text, This.Chars(I), That.Chars(I+1))
Next

Something like that, is it possible, if not, how would it be done with the string builder class?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...