select text
Når jeg vælger noget text i min RichTextBox1 og vælger anden font så ændre den i koden i Text2 felten med den selected tekst, men når man så markere noget andet og væler font så tar den den nye tekst og laver om i text2se her
http://www22.brinkster.com/hirayz/vb
download
http://www22.brinkster.com/hirayz/vb/vb.rar
........................
man skal faktisk kunne formatere teksten lige som i notepad i richtextbox1 og så skal den skrive det samme i text2 bare med HTML kode omkring...
hvis der er nogen der kender eks. rundt omkring på nettet der ikke bruger et eller andet komponent så kan det også hjælpe
HJÆÆÆÆÆÆLP!!!
Text2.text = \"<Font Name=\" & Chr(34) & RichTextBox1.SelFontName & Chr(34) & \" Size=\" & Chr(34) & htmlfontsize & Chr(34) & \" Color=\" & Chr(34) & Hex(CDFont.Color) & Chr(34) & \">\" & RichTextBox1.SelText & \"</Font>\"
HELE KODEN:
Public Event Change(text As String)
Private Sub Command1_Click()
RichTextBox1_Change
CDFont.ShowColor
RichTextBox1.SelColor = CDFont.Color
End Sub
Private Sub RichTextBox1_Change()
Dim temp
RaiseEvent Change(Text2.text)
If Combo1.ListIndex = 0 Then
RichTextBox1.SelFontName = \"Arial\"
End If
If Combo1.ListIndex = 1 Then
RichTextBox1.SelFontName = \"Courier\"
End If
If Combo1.ListIndex = 2 Then
RichTextBox1.SelFontName = \"Courier New\"
End If
If Combo1.ListIndex = 3 Then
RichTextBox1.SelFontName = \"Verdana\"
End If
If Combo1.ListIndex = 4 Then
RichTextBox1.SelFontName = \"Helvetica\"
End If
If Combo1.ListIndex = 5 Then
RichTextBox1.SelFontName = \"MS Serif\"
End If
If Combo1.ListIndex = 6 Then
RichTextBox1.SelFontName = \"Tahoma\"
End If
If Combo1.ListIndex = 7 Then
RichTextBox1.SelFontName = \"Times New Roman\"
End If
If Combo2.ListIndex = 0 Then
RichTextBox1.SelFontSize = \"7,5\"
htmlfontsize = \"1\"
End If
If Combo2.ListIndex = 1 Then
RichTextBox1.SelFontSize = \"10\"
htmlfontsize = \"2\"
End If
If Combo2.ListIndex = 2 Then
RichTextBox1.SelFontSize = \"12\"
htmlfontsize = \"3\"
End If
If Combo2.ListIndex = 3 Then
RichTextBox1.SelFontSize = \"13,5\"
htmlfontsize = \"4\"
End If
If Combo2.ListIndex = 4 Then
RichTextBox1.SelFontSize = \"18\"
htmlfontsize = \"5\"
End If
If Combo2.ListIndex = 5 Then
RichTextBox1.SelFontSize = \"24\"
htmlfontsize = \"6\"
End If
If Combo2.ListIndex = 6 Then
RichTextBox1.SelFontSize = \"36\"
htmlfontsize = \"7\"
End If
Text2.text = \"<Font Name=\" & Chr(34) & RichTextBox1.SelFontName & Chr(34) & \" Size=\" & Chr(34) & htmlfontsize & Chr(34) & \" Color=\" & Chr(34) & Hex(CDFont.Color) & Chr(34) & \">\" & RichTextBox1.SelText & \"</Font>\"
If CDFont.FontBold = True Then
Text2.SelText = \"<b>\" & Text2.SelText & \"</b>\"
RichTextBox1.Font.Bold = True
End If
If CDFont.FontItalic = True Then
Text2.SelText = \"<i>\" & Text2.SelText & \"</i>\"
End If
Text2.text = Replace(Text2.text, Chr(13) & Chr(10), \"<br>\")
Text2.text = Replace(Text2.text, \"<br><br>\", \"<p>\")
End Sub
Private Sub RichTextBox1_KeyUp(KeyCode As Integer, Shift As Integer)
If (Shift And vbCtrlMask) > 0 Then
If KeyCode = 97 Or KeyCode = 65 Then
RichTextBox1.SelStart = 0
RichTextBox1.SelLength = Len(RichTextBox1.text)
End If
End If
End Sub
Private Sub combo1_click()
RichTextBox1_Change
End Sub
Private Sub combo2_click()
RichTextBox1_Change
End Sub
Private Sub UserControl_Initialize()
Combo1.AddItem \"Arial\", 0
Combo1.AddItem \"Courier\", 1
Combo1.AddItem \"Courier New\", 2
Combo1.AddItem \"Verdana\", 3
Combo1.AddItem \"Helvetica\", 4
Combo1.AddItem \"MS Serif\", 5
Combo1.AddItem \"Tahoma\", 6
Combo1.AddItem \"Times New Roman\", 7
Combo1.ListIndex = 0
Combo2.AddItem \"1 - Mindst\", 0
Combo2.AddItem \"2\", 1
Combo2.AddItem \"3\", 2
Combo2.AddItem \"4\", 3
Combo2.AddItem \"5\", 4
Combo2.AddItem \"6\", 5
Combo2.AddItem \"7 - Størst\", 6
Combo2.ListIndex = 0
End Sub
