Start New Discussion within our Software Development Community

I'm trying to allow a user to find a specific string within a DataGridView column and replace it with another string.....not necessarily requiring them to replace the whole string but to change a word within the string.

for example:
Find What: GLAND
it searchs the column and finds GLAND STEAM CONDENSER
Replace With: BLAND
updates string to BLAND STEAM CONDENSER

Dim strFind As String
Dim strReplace As String
Dim strCurrent As String

strFind = Trim(txtFind.Text)
strReplace = Trim(txtReplace.Text)
strCurrent = Trim(m_DGVParent.CurrentCell.Value.ToString)

If strFind = "" Or strReplace = "" Then
MessageBox.Show("You need values for Find and Replace", "Missing Value(s)", _
MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
'strCurrent = strCurrent.Replace(strFind, strReplace)
Replace(strCurrent, strFind, strReplace)
End If
Catch ex As Exception
'Throw exception to calling function
Throw New Exception(UserAlert.BuildErrorMessage(ex))

End Try


I hope I posted this correctly....and it's readable......I'm new, please inform me of mistakes.

This question has already been answered. Start a new discussion instead.