Member Avatar for squanch

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

Try
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)
Else
'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))
Finally

End Try


************

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

squanch,

Dim k As String = Replace("The Red Sun", "Red", "White")
msgbox(k)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.