VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Used to create a word editor

by OSAMA ALI (3 Submissions)
Category: OLE/COM/DCOM/Active-X
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Tue 12th August 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Used to create a word editor

API Declarations


you must create 12 command buttons and a rich text box editor


Rate Used to create a word editor



Dim dh As Integer
Dim dw As Integer
Dim h As Integer
Private Sub Command1_Click()
MsgBox "The selected Text is !" & RichTextBox1.SelText, , "TEXT"
End Sub

Private Sub Command10_Click()
CommonDialog1.ShowOpen
RichTextBox1.LoadFile (CommonDialog1.FileName)
Form1.Caption = CommonDialog1.FileName
End Sub

Private Sub Command11_Click()
If Form1.Caption = "Untitled" Then
CommonDialog1.ShowSave
RichTextBox1.SaveFile (CommonDialog1.FileName)
Form1.Caption = CommonDialog1.FileName
Else
RichTextBox1.SaveFile (Form1.Caption)
End If
End Sub

Private Sub Command12_Click()
Form1.Caption = "Untitled"
RichTextBox1.Text = ""
End Sub

Private Sub Command2_Click()
MsgBox "Length of the selected Text is !" & RichTextBox1.SelLength, , "LENGTH"
End Sub
Private Sub Command3_Click()
If RichTextBox1.SelBold = False Then
RichTextBox1.SelBold = True
Else
RichTextBox1.SelBold = False
End If
End Sub
Private Sub Command4_Click()
If RichTextBox1.SelItalic = False Then
RichTextBox1.SelItalic = True
Else
RichTextBox1.SelItalic = False
End If
End Sub

Private Sub Command5_Click()
If RichTextBox1.SelUnderline = False Then
RichTextBox1.SelUnderline = True
Else
RichTextBox1.SelUnderline = False
End If
End Sub

Private Sub Command6_Click()
If RichTextBox1.SelStrikeThru = False Then
RichTextBox1.SelStrikeThru = True
Else
RichTextBox1.SelStrikeThru = False
End If
End Sub

Private Sub Command7_Click()
Dim s As Integer
s = InputBox("Enter the size of the Font", "FONT")
RichTextBox1.SelFontSize = s
End Sub

Private Sub Command8_Click()
CommonDialog1.ShowColor
RichTextBox1.SelColor = CommonDialog1.Color
End Sub

Private Sub Command9_Click()
CommonDialog1.Flags = 1
CommonDialog1.ShowFont
RichTextBox1.SelFontName = CommonDialog1.FontName
End Sub

Private Sub Form_Load()
dh = Form1.Height - RichTextBox1.Height
dw = Form1.Width - RichTextBox1.Width
h = RichTextBox1.Height
w = RichTextBox1.Width
End Sub

Private Sub Form_Resize()
If Form1.Width > 7000 Then
RichTextBox1.Height = Form1.Height - dh
RichTextBox1.Width = Form1.Width - dw
Else
RichTextBox1.Height = h
RichTextBox1.Width = w
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Form1.Caption = "Untitled" Then
CommonDialog1.ShowSave
RichTextBox1.SaveFile (CommonDialog1.FileName)
Form1.Caption = CommonDialog1.FileName
Else
RichTextBox1.SaveFile (Form1.Caption)
End If
MsgBox "Good Bye", , "End Program"
End
End Sub

Private Sub RichTextBox1_SelChange()
If RichTextBox1.DataChanged = True Then
Form1.Caption = "Untitled"
End If
Dim a As Boolean
a = ((RichTextBox1.SelLength) > 1)
If a = True Then
Form1.Caption = "Untitled"
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Else
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
End If
End Sub


Download this snippet    Add to My Saved Code

Used to create a word editor Comments

No comments have been posted about Used to create a word editor. Why not be the first to post a comment about Used to create a word editor.

Post your comment

Subject:
Message:
0/1000 characters