[精品論文]VB高級編程論文VB程序設計論文_第1頁
[精品論文]VB高級編程論文VB程序設計論文_第2頁
[精品論文]VB高級編程論文VB程序設計論文_第3頁
[精品論文]VB高級編程論文VB程序設計論文_第4頁
[精品論文]VB高級編程論文VB程序設計論文_第5頁
已閱讀5頁,還剩5頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

畢業(yè)設計課程定做 QQ1714879127VB程序設計課程設計:VB程序設計論文前 言記事本:英文名稱為:WORDPAD或NOTEPAD。 現(xiàn)在一般特指Windows操作系統(tǒng)附帶的一個簡單的文本編輯、瀏覽軟件Notepad。記事本只能處理純文本文件,但是,由于多種格式源代碼都是純文本的,所以記事本也就成為了使用最多的源代碼編輯器。 它只具備最基本的編輯功能,所以體積小巧,啟動快,占用內存低,容易使用。 記事本的功能只有:新建,保存,打印,查找,替換這幾個功能。但是記事本:打開速度快,文件小。 記事本可以保存無格式文件。你可以把記事本編輯的文件保存為:“.html”, “.java”,“.asp”等等任意格式。 所以我們學習VB程序,利用VB編寫一款簡單的基本的文本處理辦公軟件,類似于記事本,基本可以實現(xiàn)記事本的功能。因為制作者的能力有限,只是實現(xiàn)了簡單的基礎功能,所以,為提供軟件的可行性、安全性、穩(wěn)定性,我們將在以后的版本中不斷改進。 一、 功能描述1. 打開記事本菜單欄“文件”菜單具有新建文本文檔、保存(另存)文檔以及打開等功能。 2編輯 編輯可實現(xiàn)撤銷、剪切、復制、粘貼、刪除、查找、替換等功能;同時亦可實現(xiàn)插入時間日期的功能。 3格式 格式可實現(xiàn)自動換行的功能以及字體、字號、顏色的選擇。4幫助對記事本程序的版權聲明,本記事本所有程序設計與編寫均屬原創(chuàng)。二、 程序代碼記事本應用程序的詳細代碼如下:Dim sFind As String 定義sfind為一個字符型變量Dim FileType, FiType As String 定義filetype,fitype為一個字符型變量Dim txtchange As Boolean 定義txtchange為一個邏輯型變量Dim isave As BooleanPrivate Sub About_Click() MsgBox 記事本 2010 版權所有(C) , vbOKOnly, 關于記事本End SubPrivate Sub Asave_Click() CommonDialog1.CancelError = True 調用公共對話框 On Error GoTo errhandler CommonDialog1.DialogTitle = 另存為 通用對話框的標題為“另存為” CommonDialog1.InitDir = c:windows 初始化路徑 CommonDialog1.FileName = *.txt CommonDialog1.Filter = text files(*.txt)|*.txt 文件過濾器 CommonDialog1.ShowSave Open CommonDialog1.FileName For Output As #1 文件名 Print #1, Mid(text1.Text, 1, Len(text1.Text) Close #1errhandler:Exit SubEnd SubPrivate Sub Copy_Click() Clipboard.SetText RichTextBox1.SelRTF 剪切板得到的文本來自于文本框得到的文本End SubPrivate Sub Cut_Click() Clipboard.Clear 清空剪切板內容 Clipboard.SetText RichTextBox1.SelText 剪切板得到的文本來自于文本框得到的文本 RichTextBox1.SelText = 清空剪切板內容End SubPrivate Sub Date_Click() RichTextBox1.SelText = Now() 顯示當前日期和時間End SubPrivate Sub Delete_Click() RichTextBox1.SelText = End SubPrivate Sub Exit_Click() EndEnd SubPrivate Sub Find_Click()sFind = InputBox(請輸入要查找的字、詞:, 查找內容, sFind)RichTextBox1.Find sFindEnd SubPrivate Sub FindOn_Click() RichTextBox1.SelStart = RichTextBox1.SelStart + RichTextBox1.SelLength + 1 RichTextBox1.Find sFind, , Len(RichTextBox1)End SubPrivate Sub Font_Click()On Error Resume Next CommonDialog1.Flags = &H3 Or &H1 Or &H2 Or &H100 CommonDialog1.Action = 4 RichTextBox1.Font.Name = CommonDialog1.FontName 設置名稱 RichTextBox1.Font.Size = CommonDialog1.FontSize 設置字號 RichTextBox1.Font.Bold = CommonDialog1.FontBold 設置粗體 RichTextBox1.Font.Italic = CommonDialog1.FontItalic 設置斜體 RichTextBox1.Font.Underline = CommonDialog1.FontUnderline 設置下劃線 RichTextBox1.Font.setcolor = CommonDialog1.Color 設置顏色End SubPrivate Sub Form_Load() 窗體大小 Me.Height = 6000 Me.Width = 9000 txtchange = False isave = FalseEnd SubPrivate Sub Form_Resize() 文本框隨窗體大小改變On Error Resume Next RichTextBox1.Top = 20 RichTextBox1.Left = 20 RichTextBox1.Height = ScaleHeight - 40 RichTextBox1.Width = ScaleWidth - 40End SubPrivate Sub Form_Unload(Cancel As Integer)If txtchange = True And isave = False Then Call save Else End End IfEnd SubPrivate Sub mnuSave_Click() Call save 調出保存過程 isave = TrueEnd SubPrivate Sub Open_Click() CommonDialog1.Filter = 文本文檔(*.txt)|*.txt|RTF文檔(*.rtf)|*.rtf|所有文件(*.*)|*.* CommonDialog1.ShowOpen 新建一個記事本 RichTextBox1.Text = 清空原記事本的內容 FileName = CommonDialog1.FileName RichTextBox1.LoadFile FileName 打開文件函數表達式Me.Caption = 記事本: & FileNameEnd SubPrivate Sub Paste_Click()RichTextBox1.SelText = Clipboard.GetText 復制所選至剪切板End SubPrivate Sub Replace_Click() Dim Find As String, change As String, xuan As String 定義為字符型函數 Dim i As Long, len1 As Long, len2 As Long, n As Long Find = InputBox(要查找的內容) change = InputBox(要替換的內容) len1 = Len(Find) len2 = Len(RichTextBox1.Text) For i = 1 To len2 - len1 + 1 If Find = Mid(RichTextBox1.Text, i, len1) Then RichTextBox1.SetFocus RichTextBox1.SelStart = i - 1 RichTextBox1.SelLength = len1 xuan = 是否替換 n = MsgBox(xuan, vbYesNoCancel + vbDefaultButton1 + vbQuestion) If n = 6 Then RichTextBox1.SelText = change End If End If Next i End SubPrivate Sub Edit_Click() If RichTextBox1.SelText = Then 內容為空,則復制、刪除、剪切不可用 Copy.Enabled = False Cut.Enabled = False Delete.Enabled = False Else Delete.Enabled = True Copy.Enabled = True Cut.Enabled = True End If If RichTextBox1.Text = Then Find.Enabled = False FindOn.Enabled = False Else Find.Enabled = True FindOn.Enabled = True End IfEnd SubPrivate Sub RichTextBox1_Change() txtchange = True End SubPrivate Sub SelectAll_Click()RichTextBox1.SelStart = 0 RichTextBox1.SelLength = Len(RichTextBox1.Text) End SubPrivate Sub Topic_Click()On Error GoTo handler RichTextBox1.LoadFile Readme.txt, rtfText Me.Caption = 記事本: & 使用說明Exit Subhandler: MsgBox 抱歉,內容未找到!, 64, 提示 彈出提示對話框End SubPrivate Sub RichTextBox1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 2 Then PopupMenu Edit, vbPopupMenuLeftAlign Else Exit Sub End IfEnd SubPrivate Sub xinjian_Click() RichTextBox1.Text = 清空文本文檔 FileName = 未命名 更改文檔的Caption屬性 Me.Caption = FileNameEnd SubPublic Sub save() CommonDialog1.Filter = 文本文檔(*.txt)|*.txt|RTF文檔(*.rtf)|*.rtf|所有文件(*.*)|*.* CommonDialog1.ShowSave FiType = CommonDialog1.FileTitle FiType = LCase(Right(FileType, 3) FileName = CommonDialog1.FileName Select Case FileType Case txt RichTextBox1.SaveFile FileName, rtfText Case rtf RichTextBox1.SaveFile FileName, rtfRTF Case *.* RichTextBox1.SaveFile FileName End Select Me.Caption = 記事本: & FileNameEnd Sub(程序代碼編寫結束)三、 運行界面界面1.如下: 界面2.如下: 四、 運行中存在的問題與不足1 沒有實現(xiàn)狀態(tài)欄的功能;2 打開時有時會出現(xiàn)如下錯誤:3 創(chuàng)新功能不足,因為操作著能力有限,記事本可觀性與實用性較差,會在以后的程序中加以改進;4 部分代碼設計較為繁瑣。五、 心得與體會1 編寫較大程序之前需要提前計算好算法,并且作以規(guī)劃。如記事本程序中,首先應該設計好各級菜單,其次每

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論