Sunteți pe pagina 1din 36

TEXT EDITOR

ABSTRACT
A Text Editor is an application used to create, open, save and print the documents. It is also used to modify the prewritten documents. A Text Editor Workspace may also do the modification of the documents. A Text Editor is a type of program used for editing the text file. In this part, we are going to concentrate on the file operations worked using the common dialog circuit. The operations are opening and writing to files, transferring one to other, editing and so on. And also, it includes scale height and width. Which are the essential properties for designing the text editor? The project contains modules for designing the text editor with file menu, edit menu and format many using visual basic. The modules used in this project are: 1) File 2) Edit 3) Search The file menu contains the options like New, Open, Save, Save as and exit. The Edit menu contains the options like Cut, Copy, Paste, Undo and Redo. The search menu contains the options like Find, Find all.

ATTRIBUTE MATRIX: This Attribute Matrix provides various attributes that used in the project. It is used to see if the current project requirements are being met, and to help in the creation of a Request for Proposal, various deliverable documents, and project plan tasks.

TRACEABILTY MATRIX: Traceability matrix provides the overview of interdependencies between various modules.

TRACEABILITY TREE(TRACED INTO): This provides the view of what are all the attributes that depends on a particular attribute in the form of a tree structure.

TRACEABILITY TREE(TRACED OUT OF): This provides the view of what are all the attributes on which a particular attribute depends in the form of a tree structure

USE CASE DIAGRAM

Open

User

Save

Print Exit Edit

Insert

CLASS DIAGRAM

SEQUENCE DIAGRAM GENERAL


User 1: Select Text Editor 2: Welcome to Text Editor Product

OPEN/SAVE
User 1: Open/Save Option 2: Specify the File Name and File Location 3: File Name and File Location 4: Open/Save Succeed Product

PRINT
User 1: Print Option 2: Specify the Document 3: File Content 4: Print Succeed Product

EDIT
User 1: Edit Option 2: Select the Content 3: Contents to Edit 4: Edit Succeed Product

INSERT
User 1: Insert Option 2: Select Object to Insert 3: Object to Insert 4: Insert Succeed Product

EXIT

User 1: Exit Option 2: Thank You For Using

Product

COLLABORATION DIAGRAM

GENERAL
1: Select Text Editor User 2: Welcome to Text Editor Product

OPEN/SAVE
1: Open/Save Option 3: File Name and File Location User 2: Specify the File Name and File Location 4: Open/Save Succeed Product

PRINT
1: Print Option 3: File Content User 2: Specify the Document 4: Print Succeed Product

EDIT
1: Edit Option 3: Contents to Edit User 2: Select the Content 4: Edit Succeed Product

INSERT
1: Insert Option 3: Object to Insert User 2: Select Object to Insert 4: Insert Succeed Product

EXIT
1: Exit Option User 2: Thank You For Using Product

STATE CHART DIAGRAM

GENERAL

NEW

WORK SPACE

EDIT

INSERT

FORMAT

EDIT

EDIT

CUT CONTENT

COPY CONTENT

PASTE CONTENT

FIND WORD

INSERT

INSERT

DATE INSERT

TIME INSERT

ACTIVITY CHART DIAGRAM

New Document

Open No File Opened

Save

Print

Edit

Insert

File Saved

Print Succeed

Edit Succeed

Insert Succeed

Exit Option

Yes

SCREEN SHOTS FORM 1 MAIN WINDOW

FORM 2 USER WORKSPACE

FORM 3 MULTIPLE WORKSPACE

FORM 4 OPEN/SAVE OPTION

FORM 5 FIND/SEARCH OPTION

FORM 6 FORMAT OPTION

CODING MDI FORM: Dim i, Counter, startpos As Integer // Load the New Document Private Sub lodnewdoc() On Error Resume Next i=i+1 Set Form = New Form1 With Form .Caption = "New Page " & i .WindowState = vbNormal .Show End With End Sub //Default Document Loading Private Sub MDIForm_Load() On Error Resume Next lodnewdoc startpos = 1 Clipboard.Clear Me.ActiveForm.RichTextBox1.SelText = StrConv(Me.ActiveForm.RichTextBox1.SelText, vbProperCase) Me.ActiveForm.RichTextBox1.AutoVerbMenu = True End Sub

//MDI Form Resizing Private Sub MDIForm_Resize() On Error Resume Next StatusBar1.Panels.Item(1).AutoSize = sbrSpring End Sub //Copy Private Sub mnu_edit_Copy_Click() On Error Resume Next Clipboard.SetText Me.ActiveForm.RichTextBox1.SelRTF End Sub //Cut Private Sub mnu_edit_Cut_Click() On Error Resume Next Me.ActiveForm.RichTextBox2.TextRTF = Me.ActiveForm.RichTextBox2.TextRTF Clipboard.SetText Me.ActiveForm.RichTextBox1.SelRTF Me.ActiveForm.RichTextBox1.SelText = "" End Sub //Delete Private Sub mnu_edit_Delete_Click() On Error Resume Next Me.ActiveForm.RichTextBox2.TextRTF = Me.ActiveForm.RichTextBox1.TextRTF If Me.ActiveForm.RichTextBox1.SelText <> "" Then

Me.ActiveForm.RichTextBox1.SelText = "" Else Me.ActiveForm.RichTextBox1.SelLength = 1 Me.ActiveForm.RichTextBox1.SelText = "" End If End Sub //Find Private Sub mnu_edit_Find_Click() On Error Resume Next Form2.Show End Sub //Paste Private Sub mnu_edit_Paste_Click() On Error Resume Next If Clipboard.GetFormat(vbCFText) Then Me.ActiveForm.RichTextBox2.TextRTF = Me.ActiveForm.RichTextBox1.TextRTF Me.ActiveForm.RichTextBox1.SelRTF = Clipboard.GetText ElseIf Clipboard.GetFormat(vbCFRTF) Then Me.ActiveForm.RichTextBox2.TextRTF = Me.ActiveForm.RichTextBox1.TextRTF Me.ActiveForm.RichTextBox1.SelRTF = Clipboard.GetData(vbCFRTF) ElseIf Clipboard.GetFormat(vbCFBitmap) Then Me.ActiveForm.RichTextBox2.TextRTF = Me.ActiveForm.RichTextBox1.TextRTF

Me.ActiveForm.RichTextBox1.SelRTF = Clipboard.GetData End If End Sub //Replace Private Sub mnu_edit_Replace_Click() On Error Resume Next Form2.Show End Sub //Select All Private Sub mnu_edit_SelectAll_Click() On Error Resume Next Me.ActiveForm.RichTextBox1.SelStart = 0 Me.ActiveForm.RichTextBox1.SelLength = Len(Me.ActiveForm.RichTextBox1.Text) Me.ActiveForm.RichTextBox1.SetFocus End Sub //Exit Private Sub mnu_file_Exit_Click() On Error Resume Next End End Sub //New Private Sub mnu_file_New_Click() On Error Resume Next lodnewdoc

End Sub //Open Private Sub mnu_file_Open_Click() On Error Resume Next Dim sfile As String CommonDialog1.Filter = "RichText Document|*.rtf|Text Files |*.txt|All Files|*.*" CommonDialog1.ShowOpen If Len(CommonDialog1.FileName) = 0 Then MsgBox "Specify Any File", vbCritical If ActiveForm Is Nothing Then lodnewdoc Else ActiveForm.Caption = "New Page " & i End If Else sfile = CommonDialog1.FileName ActiveForm.RichTextBox1.LoadFile sfile ActiveForm.Caption = sfile End If End Sub //Print Private Sub mnu_file_Print_Click() On Error Resume Next CommonDialog1.ShowPrinter

End Sub //Save Private Sub mnu_file_Save_Click() On Error Resume Next Dim filenam As String If Me.ActiveForm.RichTextBox1.Text <> "" Then CommonDialog1.Filter = "RichText Document|*.rtf|Text Files |*.txt|All Files|*.*" CommonDialog1.ShowSave filenam = FreeFile() If CommonDialog1.FileTitle <> Empty Then Open CommonDialog1.FileName For Output As filenam If CommonDialog1.FileName = Empty Then ActiveForm.Caption = "New Page " & i End If Print #filenam, Me.ActiveForm.RichTextBox1.Text Close #filenam ActiveForm.RichTextBox1.LoadFile CommonDialog1.FileName ActiveForm.Caption = CommonDialog1.FileName End If Else MsgBox "File Cannot Saved", vbInformation End If End Sub

//Save As Private Sub mnu_file_SaveAs_Click() On Error Resume Next Dim filenam As String If Me.ActiveForm.RichTextBox1.Text <> "" Then CommonDialog1.Filter = "RichText Document|*.rtf|Text Files |*.txt|All Files|*.*" CommonDialog1.ShowSave filenam = FreeFile() If CommonDialog1.FileTitle <> Empty Then Open CommonDialog1.FileName For Output As filenam Print #filenam, Me.ActiveForm.RichTextBox1.Text Close #filenam End If lodnewdoc ActiveForm.RichTextBox1.LoadFile CommonDialog1.FileName ActiveForm.Caption = CommonDialog1.FileName Else MsgBox "File Cannot Save", vbInformation End If End Sub //Alignment Center Private Sub mnu_format_align_Center_Click() On Error Resume Next

Me.ActiveForm.RichTextBox1.SelAlignment = 2 mnu_format_align_Left.Checked = False mnu_format_align_Right.Checked = False End Sub //Alignment Left Private Sub mnu_format_align_Left_Click() On Error Resume Next Me.ActiveForm.RichTextBox1.SelAlignment = 0 mnu_format_align_Center.Checked = False mnu_format_align_Right.Checked = False End Sub //Alignment Right Private Sub mnu_format_align_Right_Click() On Error Resume Next Me.ActiveForm.RichTextBox1.SelAlignment = 1 mnu_format_align_Center.Checked = False mnu_format_align_Left.Checked = False End Sub //Font Private Sub mnu_format_Font_Click() On Error Resume Next fontselect End Sub //Word Count Private Sub mnu_format_wordcount_Click()

On Error Resume Next Dim strrtf As String Dim tem As String Dim words As Single, characters As Single, lines As Single, noc As Single, spaces As Single, i As Single Dim curchar As String Dim valid As Boolean Screen.MousePointer = vbHourglass strrtf = Me.ActiveForm.RichTextBox1.Text noc = Len(strrtf) i=1 Do While i <= noc curchar = Mid(strrtf, i, 1) If curchar = "" Then spaces = spaces + 1 words = words + 1 temp = Mid(strrtf, i + 1, 1) If temp = "" Then i=i+1 Do While temp = "" i=i+1 temp = Mid(strrtf, i, 1) spaces = spaces + 1 Loop End If

ElseIf curchar = Chr(13) Or curchar = "." Or curchar = "!" Or curchar = "?" Or curchar = ";" Then lines = lines + 1 words = words + 1 ElseIf curchar = ":" Or curchar = ";" Then words = words + 1 Else characters = characters + 1 End If i=i+1 Loop lines = lines + 1 words = words + 1 Screen.MousePointer = vbNormal MsgBox "Number of Words " & words & vbCrLf & "Number of Lines " & lines & vbCrLf & "Number of Spaces" & spaces & vbCrLf & "Number of Characters" & characters End Sub //Date (DD/MM/YYYY) Private Sub mnu_insert_dat_ddmmyyyy_Click() On Error Resume Next Me.ActiveForm.RichTextBox1.Text = Me.ActiveForm.RichTextBox1.Text & Format(Date, "dd/mm/yyyy") End Sub //Date (MM/DD/YYYY) Private Sub mnu_insert_dat_mmddyyyy_Click()

On Error Resume Next Me.ActiveForm.RichTextBox1.Text = Me.ActiveForm.RichTextBox1.Text & Format(Date, "mm/dd/yyyy") End Sub //Date (YYYY/MM/DD) Private Sub mnu_insert_dat_yyyymmdd_Click() On Error Resume Next Me.ActiveForm.RichTextBox1.Text = Me.ActiveForm.RichTextBox1.Text & Format(Date, "yyyy/mm/dd") End Sub //Time (HH:MM:SS) Private Sub mnu_insert_time_hhmmss_Click() On Error Resume Next Me.ActiveForm.RichTextBox1.Text = Me.ActiveForm.RichTextBox1.Text & Format(Time, "hh:mm:ss") End Sub //Time (Now) Private Sub mnu_insert_time_now_Click() On Error Resume Next Me.ActiveForm.RichTextBox1.Text = Me.ActiveForm.RichTextBox1.Text & Format(Date, Now) End Sub //Status Bar Private Sub mnu_view_StatusBar_Click() On Error Resume Next mnu_view_StatusBar.Checked = Not mnu_view_StatusBar.Checked

StatusBar1.Visible = Not StatusBar1.Visible End Sub //Tool Bar Private Sub mnu_view_Tool_Click() On Error Resume Next mnu_view_Tool.Checked = Not mnu_view_Tool.Checked Toolbar1.Visible = Not Toolbar1.Visible End Sub //Font Select Sub fontselect() On Error Resume Next CommonDialog1.Flags = cdlCFBoth Or cdlCFEffects Or cdlCFTTOnly CommonDialog1.ShowFont With Me.ActiveForm.RichTextBox1 .SelFontName = CommonDialog1.FontName .SelFontSize = CommonDialog1.FontSize .SelBold = CommonDialog1.FontBold .SelItalic = CommonDialog1.FontItalic .SelStrikeThru = CommonDialog1.FontStrikethru .SelUnderline = CommonDialog1.FontUnderline .SelColor = CommonDialog1.Color End With End Sub

//Tool Select Private Sub Toolbar1_ButtonClick(ByVal Button As ComctlLib.Button) If Toolbar1.Buttons.Item(1).Value = tbrPressed Then mnu_file_New_Click Toolbar1.Buttons.Item(1).Value = tbrUnpressed ElseIf Toolbar1.Buttons.Item(2).Value = tbrPressed Then mnu_file_Open_Click Toolbar1.Buttons.Item(2).Value = tbrUnpressed ElseIf Toolbar1.Buttons.Item(3).Value = tbrPressed Then mnu_file_Save_Click Toolbar1.Buttons.Item(3).Value = tbrUnpressed ElseIf Toolbar1.Buttons.Item(4).Value = tbrPressed Then mnu_file_Print_Click Toolbar1.Buttons.Item(4).Value = tbrUnpressed ElseIf Toolbar1.Buttons.Item(5).Value = tbrPressed Then mnu_edit_Cut_Click Toolbar1.Buttons.Item(5).Value = tbrUnpressed ElseIf Toolbar1.Buttons.Item(6).Value = tbrPressed Then mnu_edit_Copy_Click Toolbar1.Buttons.Item(6).Value = tbrUnpressed ElseIf Toolbar1.Buttons.Item(7).Value = tbrPressed Then mnu_edit_Paste_Click Toolbar1.Buttons.Item(7).Value = tbrUnpressed End If End Sub

FORM 1: //Form 1 Loading Private Sub Form_Load() gintindex = 1 Form_Resize RichTextBox2.Visible = False RichTextBox3.Visible = False Picture1.Visible = False End Sub //Form 1 Resizing Private Sub Form_Resize() On Error Resume Next Me.RichTextBox1.Move 0, 0, MDIForm1.ScaleWidth, MDIForm1.ScaleHeight End Sub

FORM 2: //Find Dim wordpos, startpos As Integer Private Sub Command1_Click() Dim found As Boolean found = MDIForm1.ActiveForm.RichTextBox1.Find(Text1.Text, MDIForm1.ActiveForm.RichTextBox1.SelStart + Len(Text1.Text)) If found = False Then MsgBox "Search text not found" Else MsgBox "String Found" wordpos = InStr(startpos, MDIForm1.ActiveForm.RichTextBox1.Text, Text1.Text, vbBinaryCompare) If wordpos <> 0 Then MDIForm1.ActiveForm.RichTextBox1.SelStart = wordpos - 1 MDIForm1.ActiveForm.RichTextBox1.SelLength = Len(Text1.Text) startpos = wordpos + Len(Text1.Text) End If End If Form2.Hide End Sub //Replace Private Sub Command2_Click() If Text1.Text <> Empty Then If Check1.Value Then

MDIForm1.ActiveForm.RichTextBox1.Text = Replace(MDIForm1.ActiveForm.RichTextBox1.Text, Text1.Text, Text2.Text, , 1, vbBinaryCompare) Else MDIForm1.ActiveForm.RichTextBox1.Text = Replace(MDIForm1.ActiveForm.RichTextBox1.Text, Text1.Text, Text2.Text, , 1, vbTextCompare) End If End If Form2.Hide End Sub //Replace All Private Sub Command3_Click() If Text1.Text <> Empty Then If Check1.Value Then MDIForm1.ActiveForm.RichTextBox1.Text = Replace(MDIForm1.ActiveForm.RichTextBox1.Text, Text1.Text, Text2.Text, , -1, vbBinaryCompare) Else MDIForm1.ActiveForm.RichTextBox1.Text = Replace(MDIForm1.ActiveForm.RichTextBox1.Text, Text1.Text, Text2.Text, , -1, vbTextCompare) End If End If Form2.Hide End Sub

//Form 2 Loading Private Sub Form_Load() startpos = 1 Text1.Text = "" Text2.Text = "" End Sub

FORM 3: //Splash Screen Private Sub Timer1_Timer() ProgressBar1.Value = ProgressBar1.Value + 5 If ProgressBar1.Value = 100 Then Unload Me MDIForm1.Show Timer1.Enabled = False End If End Sub

CONCLUSION

Thus the text editor is developed with basic functionalities for creating a new file or editing the existing file. Even though it looks simple but it has all the necessary features that a text editor should contain. This can be used as an alternative to notepad and still this text editor can be improved by adding some additional features that could make it even more efficient.

S-ar putea să vă placă și