CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2012
    Posts
    6

    [RESOLVED] Textbox question

    Hi,

    I have a textbox and a richtextbox, if the value in textbox matches any value in the richtext box then I want to display text in a label.

    I have some coding but its not exactly what I'm after

    Code:
    if Richtextbox1.text.Contains(Textbox1.text)
    The problem with the above code is that it doesnt check the whole value in richtextbox1 ie if richtextbox has

    Tom 22 12 52
    Ant 86 73 91

    and textbox has '1' the label will display when it should only display if the textbox has value of 22, 12, 52, 86, 73, or 91.

    what have i done wrong? thanks

  2. #2
    Join Date
    Jan 2009
    Posts
    596

    Re: Textbox question

    Split the string from the Rich Text box, using space as a separator. Then compare the text from Textbox1 with each of these strings in turn.

    Documentation here:
    http://msdn.microsoft.com/en-us/library/b873y76a.aspx

  3. #3
    Join Date
    Apr 2012
    Posts
    6

    Re: Textbox question

    Sorry im very much a newbie, could you give me a quick example?


    Code:
           Dim split As String() = words.Split(New [Char]() {" "c, CChar(vbTab) })
    
            For Each s As String In  split
                If s.Trim() <> "" Then
                    Console.WriteLine(s)
                End If
            Next s
        
    If textbox1.text = S then
    ' my coding

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

Featured