0

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!!

2
Contributors
7
Replies
22
Views
3 Years
Discussion Span
Last Post by JaneLewis1615
1

nowhere, that's the whole code.

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

Edited by oussama_1

0

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
0

forget about indexes and integers, try this

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

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

Edited by JaneLewis1615: Forgot something.

Attachments vb1.png 416.76 KB
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.