Results 1 to 3 of 3

Thread: String.Replace not working [Resolved]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    String.Replace not working [Resolved]

    In the code below, the .Replace function appears to run w/o error when I step through the code, but it doesn't replace the string. The original string is left intact. What's going wrong? Thanks.
    VB Code:
    1. Private Sub SetQuestionSql(ByVal cb As CheckBox)
    2.         Select Case cb.Name
    3.             Case "cbModule"
    4.                 If cb.Checked = True Then
    5.                     If mblnChanged Then
    6.                         mstrQuestionSQL &= " AND modcode = "
    7.                     Else
    8.                         mstrQuestionSQL &= " WHERE modcode =  "
    9.                         mblnChanged = True
    10.                     End If
    11.                 Else
    12.                     If mstrQuestionSQL.IndexOf("AND modcode = ") <> -1 Then
    13.                         mstrQuestionSQL.Replace("AND modcode = ", "")
    14.                     Else
    15.                         mstrQuestionSQL.Replace("WHERE modcode = ", "")
    16.                     End If
    17.                 End If
    Last edited by salvelinus; May 7th, 2004 at 10:06 AM.

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    mstrQuestionSQL = mstrQuestionSQL.Replace("AND modcode = ", "")

    Replace is a function that returns the result. You still have 6o apply that change to the string.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    Duh! Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width