vb.net记事本功能的简单介绍

用vb.net编写记事本源代码

Dim sFileName As String

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名与空间、网络空间、营销软件、网站建设、柳南网站维护、网站推广。

Dim Search

Private Sub dateTimeMenu_Click()

Text1.Text = Now

End Sub

Private Sub deleteMenu_Click()

Text1.Text = Left(Text1.Text, Text1.SelStart) + Mid(Text1.Text, Text1.SelStart + Text1.SelLength + 1)

End Sub

Private Sub findMenu_Click()

Search = InputBox("请输入要查找的字词:")

Dim Where1 '获取需要查找的字符串变量

Text1.SetFocus '文本框获得焦点,以显示所找到的内容Search = InputBox("请输入要查找的字词:")

Where1 = InStr(Text1.Text, Search) '在文本中查找字符串

If Where1 Then

'若找到则设置选定的起始位置并使找到的字符串高亮

Text1.SelStart = Where1 - 1

Text1.SelLength = Len(Search)

' Me.Caption = Where1 '测试用

'否则给出提示

Else: MsgBox "未找到所要查找的字符串。", vbInformation, "提示"

End If

End Sub

Private Sub findNextMenu_Click()

Dim Where2

Dim StartMe As Integer '查找的起始位置变量

Text1.SetFocus '文本框获得焦点

StartMe = Text1.SelLength + Text1.SelStart + 1 '给变量赋值

Where2 = InStr(StartMe, Text1.Text, Search) '令其从上次找到的地方找起

If Where2 Then

Text1.SelStart = Where2 - 1

Text1.SelLength = Len(Search)

Else: MsgBox "未找到所要查找的字符串.", vbInformation, "提示"

End If

End Sub

Private Sub aboutMenu_Click()

MsgBox Space(2) "文本编辑器版本号1.0" Chr(13) "由西南财经大学天府学院" Chr(13) Space(5) "肖忠 开发" Chr(13) Space(2) "copyright:天府学院"

End Sub

Private Sub allMenu_Click()

Text1.SelStart = 0

Text1.SelLength = Len(Text1.Text)

End Sub

Private Sub backcolorMenu_Click() '设置背景色代码

Form1.CommonDialog1.Action = 3

Text1.BackColor = Form1.CommonDialog1.Color

End Sub

Private Sub colorMenu_Click() '改变文字颜色代码

Form1.CommonDialog1.Action = 3

Text1.ForeColor = Form1.CommonDialog1.Color

End Sub

Private Sub cutMenu_Click()

Clipboard.SetText Text1.SelText

Text1.Text = Left(Text1.Text, Text1.SelStart) + Mid(Text1.Text, Text1.SelStart + Text1.SelLength + 1)

End Sub

Private Sub exitMenu_Click()

End

End Sub

Private Sub fontMenu_Click() '字体菜单代码

Form1.CommonDialog1.Flags = 3 Or 256

Form1.CommonDialog1.Action = 4

If Len(Form1.CommonDialog1.FontName) = 0 Then

Form1.Text1.FontName = "宋体"

Else

Form1.Text1.FontName = Form1.CommonDialog1.FontName

End If

Form1.Text1.FontSize = Form1.CommonDialog1.FontSize

If Form1.CommonDialog1.FontBold = True Then

Form1.Text1.FontBold = True

Else

Form1.Text1.FontBold = False

End If

If Form1.CommonDialog1.FontItalic = True Then

Form1.Text1.FontItalic = True

Else

Form1.Text1.FontItalic = False

End If

Text1.ForeColor = Form1.CommonDialog1.Color

End Sub

Private Sub Form_Load()

Form1.Text1.Width = Form1.Width - 130

Form1.Text1.Height = Form1.Height

End Sub

Private Sub Form_Resize()

Form1.Text1.Width = Form1.Width - 130

Form1.Text1.Height = Form1.Height

End Sub

Private Sub help1Menu_Click()

Form1.CommonDialog1.HelpCommand = cdlHelpForceFile

Form1.CommonDialog1.HelpFile = "c:\windows\system32\winhelp.hlp"

CommonDialog1.ShowHelp

End Sub

Private Sub newMenu_Click()

If Len(Trim(Text1.Text)) = 0 Then

Form1.Caption = "我的记事本" "--" "未命名"

sFileName = "未命名"

Text1.FontSize = 15

Text1.FontName = "宋体"

Text1.Text = ""

Else

Call saveAsMenu_Click

Form1.Caption = "我的记事本" "--" "未命名"

sFileName = "未命名"

Text1.FontSize = 15

Text1.FontName = "宋体"

Text1.Text = ""

End If

End Sub

Private Sub openMenu_Click() '打开文件代码

If Len(Trim(Text1.Text)) = 0 Then

Form1.Caption = "我的记事本"

Form1.CommonDialog1.Filter = "文本文件|*.txt"

Form1.CommonDialog1.Flags = 4096

Form1.CommonDialog1.Action = 1

If Len(Form1.CommonDialog1.FileName) 0 Then

sFileName = Form1.CommonDialog1.FileName

Form1.Caption = Form1.Caption "--" Form1.CommonDialog1.FileTitle

Open sFileName For Input As #1

Text1.FontSize = 15

Text1.FontName = "宋体"

Do While Not EOF(1)

Line Input #1, Text$

All$ = All$ + Text$ + Chr(13) + Chr(10)

Loop

Text1.Text = All

Close #1

End If

Else

Call saveAsMenu_Click

Form1.Caption = "我的记事本"

Form1.CommonDialog1.Filter = "文本文件|*.txt"

Form1.CommonDialog1.Flags = 4096

Form1.CommonDialog1.Action = 1

If Len(Form1.CommonDialog1.FileName) 0 Then

sFileName = Form1.CommonDialog1.FileName

Form1.Caption = Form1.Caption "--" Form1.CommonDialog1.FileTitle

Open sFileName For Input As #1

Text1.FontSize = 15

Text1.FontName = "宋体"

Do While Not EOF(1)

Line Input #1, Text$

All$ = All$ + Text$ + Chr(13) + Chr(10)

Loop

Text1.Text = All

Close #1

End If

End If

End Sub

Private Sub pasteMenu_Click() '粘贴菜单代码

Text1.Text = Left(Text1.Text, Text1.SelStart) + Clipboard.GetText() + Mid(Text1.Text, Text1.SelStart + Text1.SelLength + 1)

End Sub

Private Sub printMenu_Click()

Form1.CommonDialog1.ShowPrinter

For i = 1 To CommonDialog1.Copies

Printer.Print Text1.Text

Printer.Print Text1.Text

Next

Printer.EndDoc

End Sub

Private Sub saveAsMenu_Click() '另存为菜单代码

If Len(Trim(Text1.Text)) 0 Then

Form1.CommonDialog1.DialogTitle = "保存文件"

Form1.CommonDialog1.InitDir = "D:\"

Form1.CommonDialog1.Filter = "文本文件|*.txt"

Form1.CommonDialog1.Flags = 2

Form1.CommonDialog1.ShowSave

If Len(Form1.CommonDialog1.FileName) 0 Then

sFileName = Form1.CommonDialog1.FileName

Open sFileName For Output As #1

whole$ = Text1.Text

Print #1, whole

Close #1

End If

End If

End Sub

Private Sub saveMenu_Click()

If Len(Trim(Text1.Text)) 0 Then

Form1.CommonDialog1.DialogTitle = "保存文件"

Form1.CommonDialog1.InitDir = "D:\"

Form1.CommonDialog1.FileName = "新建文本"

Form1.CommonDialog1.Filter = "文本文件|*.txt"

Form1.CommonDialog1.Flags = 2

Form1.CommonDialog1.ShowSave

If Len(Form1.CommonDialog1.FileName) 0 Then

sFileName = Form1.CommonDialog1.FileName

Open sFileName For Output As #1

whole$ = Text1.Text

Print #1, whole

Close #1

End If

End If

End Sub

Private Sub statusMenu_Click()

End Sub

vb.net如何用我编写的一个记事本程序通过鼠标右键菜单来打开一个文件

一、用wshshell组件的RegWrite方法写注册表,在HKEY_CLASSES_ROOT\*\Shell 位置加入的你程序,

例如:

[HKEY_CLASSES_ROOT\*\shell\我的程序\command]

@="D:\\我的程序.exe %1"

后面的%1会将文件名传送给你的程序的Command$,多文件名需要使用DDE方式进行互斥传入。

二、

将下面内容输入记事本后保存为reg文件,运行即可:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\OpenInNotepad]

@="用记事本打开"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\OpenInNotepad\command]

@="notepad.exe %1"

"用记事本打开" 为右键菜单中显示的名称

怎样在VB .NET中调用记事本和计算器

这个啊,呵呵,应该不难吧

先找到你要打开的应用程序的文件

然后用一个调用代码:

System.Diagnostics.Process.Start("C:\WINDOWS\system32\notepad.exe")

这是要开记事本的

System.Diagnostics.Process.Start("C:\WINDOWS\system32\calc.exe")

这是打开计算器的

应该也可以把这两个应用程序复制到你的程序的默认目录下,就是BIN下吧!

呵呵,试试!!要给我加分哦!!!

VB.NET:想写个代替WINDOWS里的“记事本”的软件,可文本框有字数限制,该怎么办(2017年3月22)

如果.net的标准文本框都不够长,那基本上不能用普通控件来解决了。因为标准文本框内容的长度只受限于 String 的长度,大约是2GB左右。如果它不行,那 RichTxetBox、Label 等都不行。

解决的方案:一个是读文件时就判断长度,超长的直接弹错即可。再一个是提示用户将截断。再就是自己写代码,只读取部分内容供用户查看和修改,当用户移动滚动条时再动态的读取相应部分。最后这个当然好,但难度也最大。

VB.net怎么才能实现记事本中的查找上一个的功能(在Richtextbox中)?

查找一次后记入查找内容的位置,百查找下一个功能度 这时候的开始位置就是刚才查找内容的位置加上查找内容的长度,版突出显示其实就是选权定文本,富文本框有SelectionStart,SelectionLength 两个属性

关于VB.NET制作记事本自动保存的问题

经过我的潜心修炼问题终于是解决了.请看代码

Imports System.IO

Private strFileName As String = "myRTFdoc.txt"

Private flgFirst As Boolean = True

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

'如何将程序控制住,让它第一次发现没保存后,只击活一次提示保存,然后使用修改后的保存路径

Call zc()

End Sub

Private Sub zc()

'Timer2.Stop()

With SaveFileDialog1

.DefaultExt = "txt"

.FileName = strFileName

.Filter = "Text files(*.txt)|*.txt|All files(*.*)|*.*"

.FilterIndex = 1

.InitialDirectory = "c:\"

.OverwritePrompt = True

.Title = "Save Reminding"

End With

'Timer2.Enabled = False

If flgFirst = True Then

If SaveFileDialog1.ShowDialog = DialogResult.OK Then

strFileName = SaveFileDialog1.FileName

Dim objWriter As StreamWriter = New StreamWriter(strFileName, False)

objWriter.Write(rtbox.Text)

objWriter.Close()

objWriter = Nothing

End If

flgFirst = False

'Timer2.Enabled = True

' Timer2.Start()

Else

'flg= second

Dim objWriter As StreamWriter = New StreamWriter(strFileName, False)

objWriter.Write(rtbox.Text)

objWriter.Close()

objWriter = Nothing

End If

'Timer2.Enabled = True

'Timer2.Start()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Timer2.Enabled = True

' zc()

End Sub

知道问题在哪里嘛?我调试了确实是"死循环"、其实不是真正的死循环、是time tick事件你设定的时间太短了.估计只设置了1-5s左右.那么程序运行还需要时间.所以他就不停地调用timetick时间.你的savedialog对话框根本来不急弹出来.

所以建议你把timer的interval的值设置高点最好12-15秒 触发一次.

当然我想还有其他的方法、还没有彻底取研究下.

比如stop 什么 、那还需要时间.

至少目前我的方法是可以了.

我设置的12s P4. 3.0 1G 内存 跑下我的程序如果 F10(F8)慢点的话就来不及了.

另为把你的程序小改了下、应该可以满足你的要求了.

本文题目:vb.net记事本功能的简单介绍
URL地址:https://www.cdcxhl.com/article20/doscejo.html

成都网站建设公司_创新互联,为您提供网站设计虚拟主机网站改版企业网站制作定制网站外贸网站建设

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都网站建设