home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
- Begin VB.Form Form1
- Caption = "Simple Text Editor"
- ClientHeight = 6150
- ClientLeft = 165
- ClientTop = 735
- ClientWidth = 7650
- LinkTopic = "Form1"
- ScaleHeight = 6150
- ScaleWidth = 7650
- StartUpPosition = 3 'Windows Default
- Begin VB.TextBox Editor
- Height = 5745
- HideSelection = 0 'False
- Left = 225
- MultiLine = -1 'True
- ScrollBars = 2 'Vertical
- TabIndex = 0
- Top = 210
- Width = 7230
- End
- Begin MSComDlg.CommonDialog CommonDialog1
- Left = 0
- Top = 0
- _ExtentX = 847
- _ExtentY = 847
- FontSize = 2.54052e-29
- End
- Begin VB.Menu FileMenu
- Caption = "File"
- Begin VB.Menu FileNew
- Caption = "New"
- End
- Begin VB.Menu FileOpen
- Caption = "Open"
- End
- Begin VB.Menu FileSave
- Caption = "Save"
- End
- Begin VB.Menu FileSaveAs
- Caption = "Save As"
- End
- Begin VB.Menu FileSeparator
- Caption = "-"
- End
- Begin VB.Menu FileExit
- Caption = "Exit"
- End
- End
- Begin VB.Menu EditMenu
- Caption = "Edit"
- Begin VB.Menu EditCopy
- Caption = "Copy"
- End
- Begin VB.Menu EditCut
- Caption = "Cut"
- End
- Begin VB.Menu EditPaste
- Caption = "Paste"
- End
- Begin VB.Menu EditSelect
- Caption = "Select All"
- End
- Begin VB.Menu EditSeparator
- Caption = "-"
- End
- Begin VB.Menu EditFind
- Caption = "Find"
- End
- End
- Begin VB.Menu ProcessMenu
- Caption = "Process"
- Begin VB.Menu ProcessUpper
- Caption = "Upper Case"
- End
- Begin VB.Menu ProcessLower
- Caption = "Lower Case"
- End
- Begin VB.Menu ProcessNumber
- Caption = "Number Lines"
- End
- End
- Begin VB.Menu CustomMenu
- Caption = "Customize"
- Begin VB.Menu CustomFont
- Caption = "Font"
- End
- Begin VB.Menu CustomPage
- Caption = "Page Color"
- End
- Begin VB.Menu CustomText
- Caption = "Text Color"
- End
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Dim OpenFile As String
- Private Sub CustomFont_Click()
- CommonDialog1.Flags = cdlCFBoth
- CommonDialog1.ShowFont
- Editor.Font = CommonDialog1.FontName
- Editor.FontBold = CommonDialog1.FontBold
- Editor.FontItalic = CommonDialog1.FontItalic
- Editor.FontSize = CommonDialog1.FontSize
- End Sub
- Private Sub CustomPage_Click()
- CommonDialog1.ShowColor
- Editor.BackColor = CommonDialog1.Color
- End Sub
- Private Sub CustomText_Click()
- CommonDialog1.ShowColor
- Editor.ForeColor = CommonDialog1.Color
- End Sub
- Private Sub EditCopy_Click()
- Clipboard.SetText Editor.SelText
- End Sub
- Private Sub EditCut_Click()
- Clipboard.SetText Editor.SelText
- Editor.SelText = ""
- End Sub
- Private Sub EditFind_Click()
- Form2.Show
- End Sub
- Private Sub EditPaste_Click()
- Editor.SelText = Clipboard.GetText
- End Sub
- Private Sub EditSelect_Click()
- Editor.SelStart = 0
- Editor.SelLength = Len(Editor.Text)
- End Sub
- Private Sub FileExit_Click()
- End
- End Sub
- Private Sub FileNew_Click()
- Editor.Text = ""
- OpenFile = ""
- End Sub
- Private Sub FileOpen_Click()
- Dim FNum As Integer
- Dim txt As String
- On Error GoTo FileError
- CommonDialog1.CancelError = True
- CommonDialog1.Flags = cdlOFNFileMustExist
- CommonDialog1.DefaultExt = "TXT"
- CommonDialog1.Filter = "Text files|*.TXT|All files|*.*"
- CommonDialog1.ShowOpen
- FNum = FreeFile
- Open CommonDialog1.filename For Input As #1
- txt = Input(LOF(FNum), #FNum)
- Close #FNum
- Editor.Text = txt
- OpenFile = CommonDialog1.filename
- Exit Sub
- FileError:
- If Err.Number = cdlCancel Then Exit Sub
- MsgBox "Unkown error while opening file " & CommonDialog1.filename
- OpenFile = ""
- End Sub
- Private Sub FileSave_Click()
- Dim FNum As Integer
- Dim txt As String
- If OpenFile = "" Then
- FileSaveAs_Click
- Exit Sub
- End If
- On Error GoTo FileError
- FNum = FreeFile
- Open OpenFile For Output As #1
- Print #FNum, Editor.Text
- Close #FNum
- Exit Sub
- FileError:
- If Err.Number = cdlCancel Then Exit Sub
- MsgBox "Unkown error while saving file " & OpenFile
- OpenFile = ""
- End Sub
- Private Sub FileSaveAs_Click()
- Dim FNum As Integer
- Dim txt As String
- On Error GoTo FileError
- CommonDialog1.CancelError = True
- CommonDialog1.Flags = cdlOFNOverwritePrompt
- CommonDialog1.DefaultExt = "TXT"
- CommonDialog1.Filter = "Text files|*.TXT|All files|*.*"
- CommonDialog1.ShowSave
- FNum = FreeFile
- Open CommonDialog1.filename For Output As #1
- Print #FNum, Editor.Text
- Close #FNum
- OpenFile = CommonDialog1.filename
- Exit Sub
- FileError:
- If Err.Number = cdlCancel Then Exit Sub
- MsgBox "Unkown error while saving file " & CommonDialog1.filename
- OpenFile = ""
- End Sub
- Private Sub Form_Resize()
- Editor.Width = Form1.Width - 600
- Editor.Height = Form1.Height - 1100
- End Sub
- Private Sub ProcessLower_Click()
- Dim Sel1, Sel2 As Integer
- Sel1 = Editor.SelStart
- Sel2 = Editor.SelLength
- Editor.SelText = LCase$(Editor.SelText)
- Editor.SelStart = Sel1
- Editor.SelLength = Sel2
- End Sub
- Private Sub ProcessNumber_Click()
- Dim tmpText, tmpLine As String
- Dim firstChar, lastChar As Integer
- Dim currentLine As Integer
- firstChar = 1
- currentLine = 1
- lastChar = InStr(Editor.Text, Chr$(10))
- While lastChar > 0
- tmpLine = Format$(currentLine, "000") & " " & Mid$(Editor.Text, firstChar, lastChar - firstChar + 1)
- currentLine = currentLine + 1
- firstChar = lastChar + 1
- lastChar = InStr(firstChar, Editor.Text, Chr$(10))
- tmpText = tmpText + tmpLine
- Editor.Text = tmpText
- End Sub
- Private Sub ProcessUpper_Click()
- Dim Sel1, Sel2 As Integer
- Sel1 = Editor.SelStart
- Sel2 = Editor.SelLength
- Editor.SelText = UCase$(Editor.SelText)
- Editor.SelStart = Sel1
- Editor.SelLength = Sel2
- End Sub
-