Results 1 to 3 of 3

Thread: Bottom line of textbox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2007
    Posts
    134

    Bottom line of textbox

    I am trying to see if the bottom line of the textbox contains a string, I know that the following will tell me if the textbox contains "a" but how do I narrow it down to just the last line?


    Code:
    If InStr(LCase(Text1), "a") > 0 Then
            MsgBox "Label contains <a> character."
        End If
    Thanks

  2. #2
    Hyperactive Member DavesChillaxin's Avatar
    Join Date
    Mar 2011
    Location
    WNY
    Posts
    451

    Re: Bottom line of textbox

    are your lines separated by anything like new lines or anything as such? or is it simply just a straight paragraph and you need the last line?

    You could always split up the the entire text string by either periods or the newlines, and search through the last one for the character your after.
    Please rate if my post was helpful!
    Per favore e grazie!




    Code Bank:
    Advanced Algebra Class *Update | True Gradient Label Control *Dev | A Smarter TextBox *Update | Register Global HotKey *Update
    Media Library Beta *Dev | Mouse Tracker (Available in VB.net and C#.net) *New | On-Screen Numpad (VB.net) *New

  3. #3
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    Pakistan
    Posts
    388

    Re: Bottom line of textbox

    This should be simple enough.

    Code:
    Private Sub Command1_Click()
        Dim pos As Integer
        pos = InStrRev(Text1.Text, vbNewLine)
        If pos = 0 Then
            MsgBox "The last line is: " & Text1.Text
        Else
            MsgBox "The last line is: " & Mid(Text1.Text, pos + 2)
        End If
    End Sub
    If your problem is solved, then drag down the Thread Tools and mark your thread as Resolved.

    If I helped you solve your problem, inflate some air into my ego by rating my post and adding a comment too.

    For notorious issues (elaborate yourself) contact me via PM. I don't answer them in the forums EVER.

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