borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (What does it mean?)Next Topic (Insert not working) New Topic New Poll Post Reply
AndreaVB Forum : Database : Text Box Formatting in Forms
Poster Message
Andgramar
Level: Big Cheese

Registered: 04-03-2004
Posts: 20

icon Text Box Formatting in Forms

Greetings

I'm trying to do a wild card search accross all the data in my database and return details of where the words occur.

Firstly i'm doing this by using SQL queries in VBA against each field in each table which i'm quite sure isn't the best way as I have about 54 tables so thats a lot of loops.
If anyone knows a better way i would be greatful.

The main problem I have is I want to highlight out where the word occurs in the text.
Basically what i'm asking is if there's a way of highlighting a single word from a text box by either underlining it or making it bold.

Thanks

Andy

18-10-2005 at 02:06 PM
View Profile Send Email to User Show All Posts | Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: Text Box Formatting in Forms

Sorry I think with your 54 table search unless you change your db design. But regarding the high light you can use the "microsoft rich text box" control and the code below.

Private Sub Command1_Click()

    RichTextBox1.Text = "The main problem I have is I want to highlight out where the word occurs in the text. Basically what i'm asking is if there's a way of highlighting a single word from a text box by either underlining it or making it bold."

End Sub

Private Sub Command2_Click()

    Dim position As Integer
    Dim SearchWord As String
    
    SearchWord = "Highlight"
    
    position = InStr(LCase(RichTextBox1.Text), LCase(SearchWord))
    
    Do While position > 0
    
        With RichTextBox1
        
            .SelStart = position - 1
            .SelLength = Len(SearchWord)
            .SelBold = True
            .SelUnderline = True
            .SelColor = vbRed
            .SelStart = Len(.Text)
            .SelLength = 0
            
        End With
        
        position = InStr(position + 1, LCase(RichTextBox1.Text), LCase(SearchWord))
    
    Loop

End Sub


Steve  

[Edited by steve_w on 18-10-2005 at 02:52 PM GMT]

18-10-2005 at 02:43 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : Text Box Formatting in Forms
Previous Topic (What does it mean?)Next Topic (Insert not working) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder