|
-
Mar 9th, 2003, 07:39 PM
#1
Thread Starter
Hyperactive Member
Text Formating
Does anyone know of a good way to format text like if the user types the word yes turn it blue and if the user types no turn it red, or if they type a number turn it brown? I was going to use a rich text box and just check it in the TextChanged section but my problem is to change the color or size or what not i would have to select the text. So what it is kind of like is like visual basic or C++ how do those programs change the text on the fly? And also how do they put those ~~~~~~ wavy lines below the problem areas like microsoft word does when you spell something wrong?
-
Mar 9th, 2003, 11:30 PM
#2
PowerPoster
One way to highlight the words as they are typing them in is to use the keypress event. Don't scan the whole rtb everytime though, it would be too slow. What you do is store the last 25 (or as many as you think you need) characters typed in a static variable. Every time a user types a new character, you add it to the string at the end, remove the first, then scan that string for what your looking for. Make changes, then post those changes to the rtb. This stops the scanning of the whole document every time, and would end up saving a lot of time if the document was huge.
There are many other ways to do it though, mine is just one. There might be a lot better ways.
-
Mar 10th, 2003, 10:18 AM
#3
Hyperactive Member
hi,
use richtextbox1.selcolor=vbgreen
-
Mar 10th, 2003, 11:35 AM
#4
Fanatic Member
What abot something like this:-
VB Code:
Private Sub Form_Load()
Text1.Text = vbLowerCase
End Sub
Private Sub Text1_Change()
If Text1.Text = "yes" Then
Text1.ForeColor = vbBlue
ElseIf Text1.Text = "no" Then
Text1.ForeColor = vbRed
Else
End If
If IsNumeric(Text1.Text) = True Then
Text1.ForeColor = vbGreen
End If
End Sub
-
Mar 10th, 2003, 11:51 AM
#5
Fanatic Member
This may be a littlre better. Sorry for the formatting but i have 1 minute before i go
Try this
VB Code:
Private Sub Form_Load()
Text1.Text = vbLowerCase
End Sub
Private Sub Text1_Change()
If Text1.Text = "yes" Then
Text1.ForeColor = vbBlue
ElseIf Text1.Text = "no" Then
Text1.ForeColor = vbRed
ElseIf IsNumeric(Text1.Text) = True Then
Text1.ForeColor = vbGreen
ElseIf Text1.Text <> yes And Text1.Text <> no And IsNumeric(Text1.Text) = False Then
Text1.ForeColor = vbBlack
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|