I am a beginner to VB.NET, and I am creating a program that displays a new string in a label. The new string should take a sentence entered by the user and remove every occurrence of a substring supplied by the user. This is my code so far:

    Dim input As String = txtSentence.Text
    Dim remove As String = txtTextRemove.Text
    Dim index As Integer = 0
    Do
        index = input.Remove(0, remove - 1)
    Loop While index > 0
    Me.lblAnswer.Text = index

When I enter " I really dislike that dessert.", and I want to remove "dis". In the label I should get " I really like that dessert." but instead I am getting 0. Why am I getting this? NEED HELP WITH THE CODING!!

nowhere, that's the whole code.

Label.text.replace("dis", "")

Edited 2 Years Ago by oussama_1

Dim sentence As String = txtSentence.Text
Dim remove As String = txtTextRemove.Text

    Dim index As Integer = 0


    index = sentence.ToString.Replace("dis", "")
    Me.lblAnswer.Text = index

forget about indexes and integers, try this

sentence = sentence.tostring.replace("dis","")
Me.lblAnswer.Text = sentence

This is what I am suppose to be doing. Look at the attachment.

Edited 2 Years Ago by JaneLewis1615: Forgot something.

Attachments vb1.png 416.76 KB
This question has already been answered. Start a new discussion instead.