How can I "replace" a letter in uppercase only in excel vb.net

Viewed 37

I am writing a script in vb.net and wanted to replace the "N" letter, how can I do it? It also deletes the letter in the word "online"

thank you.

        ws1.Range("F:F").Replace(("N"), "")

does also remove the N in "Online" which is the header of column F

1 Answers

You can use the String.Replace() method.

This works:

   Dim strOldString As String = "Never replace the lowercase n in online"
   Dim strNewString As String = strOldString.Replace("N", "0")
   Debug.WriteLine(strNewString)

Output:

   0ever replace the lowercase n in online

Here is the Microsoft documentation for the String.Replace() method

If this solves your question, please mark this as your accepted answer.

Related