Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8338995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:45:45+00:00 2026-06-09T04:45:45+00:00

I have a stringbuilder in VB I like to check to see if it

  • 0

I have a stringbuilder in VB

I like to check to see if it contains a value if so I like to do something:

If strMsg.Contains("<table>") Then
  ' strMsg = strMsg + "<br/><br/><br/>"
  strMsg.Append("<br/><br/><br/>")
End If

I tried the above but said contains is not a member of System.Text.StringBuilder.

What can I use in place of Contains

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:45:48+00:00Added an answer on June 9, 2026 at 4:45 am

    Contains() is not among Stringbuilder’s methods. That said, you have a couple options…

    1.: Test your values on the way in and maintain a boolean flag for your append <br> tags state.

    2.: Perform ToString() and call Contains() from the result:

    if strMsg.ToString().Contains("<table>") then '...
    

    3.: Implement IndexOf() and/or Contains() yourself:

    Module StringBuilderExtensions
    
        <Extension()>
        Public Function IndexOf(ByVal sb As StringBuilder, ByVal value As String) As Integer
    
            For i As Integer = 0 To sb.Length - value.Length - 1
    
                For y As Integer = 0 To value.Length - 1
    
                    If value(y) <> sb(i + y) Then
    
                        Exit For
    
                    ElseIf y = value.Length - 1 Then
    
                        Return i
    
                    End If
    
                Next
    
            Next
    
            Return -1
    
        End Function
    
        <Extension()>
        Public Function Contains(ByVal sb As StringBuilder, ByVal value As String) As Boolean
    
            Return sb.IndexOf(value) > -1
    
        End Function
    
    End Module
    

    Disclaimer: This hasn’t been tested for performance… and Michael Haren’s comment was directed at the ToString() option.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have something like this in my code: String boundary = thisIsMyBoundaryString; StringBuilder body
I have a stringbuilder that will look like something close to this smith;rodgers;McCalne etc
I'm have a StringBuilder that is writing content to a file. Towards the end
I have the following: StringBuilder errors = new StringBuilder(); if(IsNullOrEmpty(value)) { errors.AppendLine(Enter value); }
Suppose I have the following expressions: Expression<Action<T, StringBuilder>> expr1 = (t, sb) => sb.Append(t.Name);
I am writing a code generation tool that frequently will have lines like StringBuilder
I have a string builder like StringBuilder sb = new StringBuilder(Value1); sb.AppendLine(Value2); Now I
This should hopefully be a quick one. I have a StringBuilder like so: StringBuilder
I have to print a 5x5 table with alphabets in them, like: <table> <tr>
I have a function like this public static string GetNumberOfColumns(string ConnectionString) { StringBuilder sb

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.