PDA

Click to See Complete Forum and Search --> : Newbie Question...


Anton LaVey
Jan 11th, 2000, 01:54 AM
I have a form with a text box and three check boxes... One is called optBold one is called optItalic and the final is called optUnderline. When any of them is clicked then _all_ of the text in the text box is changed to either bold, italic, underline or a combination of all of them. What I really want is for the text in the box to stay the same and the next text that is typed to be underlined or bold or italic or whatever and so on... This is the main part of my code (I think I can remember it all)...

Private Sub optBold_Click()

If optBold Then txtMain.FontBold = True Else txtMain.FontBold = False

End Sub

...and so on for optItalic_Click() and optUnderline_Click().

Please help the newbie!
Thanks in advance...

Anton LaVey

PITBULLCJR
Jan 11th, 2000, 02:07 AM
I am not sure on what you mean but I think this is what you mean if not just email me or reply to this and hope I get it. Also you can not have 3 option buttons = true all at once unless you put them inside a fram so what I used is check Boxes so here it is.
code:
Private Sub Text1_Change()
If Check1.Value = 1 Then
Text1.FontBold = True
Else
Text1.FontBold = False
End If
If Check2.Value = 1 Then
Text1.FontItalic = True
Else
Text1.FontItalic = False
End If
If Check3.Value = 1 Then
Text1.FontUnderline = True
Else
Text1.FontUnderline = False
End If
End Sub

I hope this helps

------------------
Sincerely,
Chris
:-) ;-)
Email pitbullcr7@aol.com

Aaron Young
Jan 11th, 2000, 02:15 AM
If I understand you correctly you want to have text in the textbox of different styles, for example something like:

Hello World

If so, it's not possible with a standard Textbox, the Style used by the Textbox is used for all Text within it, so setting the Font Style to Italic, will make ALL the text in the textbox Italic.

For what you want, you need to use the RichTextbox which allows you to format the Text, you can then use the SelBold and similar properties to change the Font Style of Blocks of Text within the Same Control.

------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com

netSurfer
Jan 11th, 2000, 02:17 AM
Even that will still Bold/Italic etc the whole text box. I assume that what you mean is that if I type in 'this', then check the Bold and type in 'is bold', you want the 'is bold' to be bolded and not the 'this'? I'm not sure if you can do this. It would be like changing fonts in the middle of the text box. I don't think it's possible to do that.

Aaron beat me to it but I think you understand. :-)

[This message has been edited by netSurfer (edited 01-11-2000).]

PITBULLCJR
Jan 11th, 2000, 02:29 AM
Oh now I see what you mean there is a way to do it you would have to say that the text in the text box is a string and then when the next stuff is typed as bold then add the old string with the new string and it would work. SO it is possible but will take a little bit of hard work. Well if you need any help doing it ask.

------------------
Sincerely,
Chris
:-) ;-)
Email pitbullcr7@aol.com

Anton LaVey
Jan 11th, 2000, 03:35 AM
Yeah, thanks for the input ppl..!
I have got check boxes and a frame around them (simply for clarity) but I use optBold because my teacher told me to, I guess they should be chkBold, etc.?

Well, I can't understand why I can't do this - I don't mind whether I have to use a different control but I need to get this working some time soon... The suggestion above is a bit hard and would involve too much messy code in my opinion, thanks anyway. Any code examples would be good too!

Thanks in advance (again)...

Anton LaVey

Aaron Young
Jan 11th, 2000, 04:04 AM
Adda Richtextbox to a Form with 3 Checkboxes; (chkBold, chkItalic and chkUnderscore)..

Private bProg As Boolean

Private Sub chkBold_Click()
If bProg Then Exit Sub
RichTextBox1.SelBold = chkBold
RichTextBox1.SetFocus
End Sub

Private Sub chkItalic_Click()
If bProg Then Exit Sub
RichTextBox1.SelItalic = chkItalic
RichTextBox1.SetFocus
End Sub

Private Sub chkUnderscore_Click()
If bProg Then Exit Sub
RichTextBox1.SelUnderline = chkUnderscore
RichTextBox1.SetFocus
End Sub

Private Sub RichTextBox1_SelChange()
With RichTextBox1
bProg = True
If Not IsNull(.SelBold) Then chkBold = Abs(.SelBold)
If Not IsNull(.SelItalic) Then chkItalic = Abs(.SelItalic)
If Not IsNull(.SelUnderline) Then chkUnderscore = Abs(.SelUnderline)
bProg = False
End With
End Sub



------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com