vb的简单记事本的代码

那为大哥能帮我做一个vb的记事本的代码知道的加QQ83297077,有人会吗?提供流程图,代码,还有运行截图,提供QB奖励... 那为大哥能帮我做一个vb的记事本的代码
知道的加QQ83297077,有人会吗?提供流程图,代码,还有运行截图,提供QB奖励
展开
 我来答
love_u365s
推荐于2017-09-17 · TA获得超过983个赞
知道小有建树答主
回答量:1269
采纳率:50%
帮助的人:0
展开全部
'窗体代码

Option Explicit
Dim filename As String
Dim FileType As String
Dim FiType As String
Dim sFind As String
Dim result As String
Dim bWrap As Boolean
Dim ask As Boolean
Dim msgtext As String
Dim Flag As String

Private Sub Form_Load()
ask = False
RichText.Text = ""
filename = "无标题-记事本"
Form1.Caption = "无标题-记事本"
RichText.Height = Form1.ScaleHeight
RichText.Width = Form1.ScaleWidth
StatusBar1.Visible = False
StatusBar1.Panels(1).Text = Time
mnucopy.Enabled = False
mnucut.Enabled = False
mnufound.Enabled = False
mnufoundnext.Enabled = False
mnudel.Enabled = False
mnucancel.Enabled = False
mnuwordwrap.Checked = True
mnugoto.Enabled = False
If Clipboard.GetText <> "" Then
mnuplaster.Enabled = True
Else
mnuplaster.Enabled = False
End If
App.HelpFile = App.Path & "\notepad.chm"
End Sub

Private Sub Form_Resize()
RichText.Height = Form1.ScaleHeight
RichText.Width = Form1.ScaleWidth
End Sub

Private Sub Form_Unload(Cancel As Integer)
msgtext = "文件" & filename & "的文字已经改变。" & Chr(10) & Chr(13) & "想保存文件吗?"
If ask = True Then
Flag = MsgBox(msgtext, 35, "记事本") ' 35=32+3
If Flag = vbYes Then mnusave_Click '选择了确定则保存之
If Flag = vbCancel Then Cancel = True
If Flag = vbNo Then Unload Me
End If

End Sub

Private Sub mnuabout_Click()
MsgBox "记事本", vbOKOnly, "关于"
End Sub

Private Sub mnuall_Click()
RichText.SelStart = 0
RichText.SelLength = Len(RichText.Text)
End Sub

Private Sub mnucancel_Click()
MsgBox "请点击鼠标右键撤销!", vbOKOnly, "提示"
End Sub

Private Sub mnucopy_Click()
Clipboard.Clear
Clipboard.SetText RichText.SelText
End Sub

Private Sub mnucut_Click()
Clipboard.Clear
Clipboard.SetText RichText.SelText
RichText.SelText = ""

End Sub

Private Sub mnudel_Click()
RichText.SelText = ""
End Sub

Private Sub mnuedit_Click()
If RichText.SelText <> "" Then
mnuopen.Enabled = True
mnucut.Enabled = True
mnudel.Enabled = True
mnucopy.Enabled = True
End If
If Len(RichText.Text) <> 0 Then
mnufound.Enabled = True
mnufoundnext.Enabled = True
End If
If ask = True Then mnucancel.Enabled = True
End Sub

Private Sub mnuexit_Click()
Unload Me
End Sub

Private Sub mnufont_Click()
On Error Resume Next
CommonDialog1.flags = &H3 Or &H1 Or &H2 Or &H100
CommonDialog1.Action = 4
RichText.Font.Name = CommonDialog1.FontName
RichText.Font.Size = CommonDialog1.FontSize
RichText.Font.Bold = CommonDialog1.FontBold
RichText.Font.Italic = CommonDialog1.FontItalic
RichText.Font.Underline = CommonDialog1.FontUnderline
RichText.SelColor = CommonDialog1.Color

End Sub

Private Sub mnufound_Click()
sFind = InputBox("请输入要查找的字、词:", "查找内容", sFind)
RichText.Find sFind
End Sub

Private Sub mnufoundnext_Click()
RichText.SelStart = RichText.SelStart + RichText.SelLength + 1
RichText.Find sFind, , Len(RichText)

End Sub

Private Sub mnuhelptopic_Click()
SendKeys "{F1}"
End Sub

Private Sub mnunewfile_Click()
On Error Resume Next
Dim n As Integer
msgtext = "文件" & filename & "的文字已经改变。" & Chr(10) & Chr(13) & "想保存文件吗?"
If Len(RichText.Text) <> 0 Then
If filename = "无标题-记事本" Then
Flag = MsgBox(msgtext, 35, "记事本") '给予提示
If Flag = vbYes Then
mnusaveas_Click
RichText.Text = ""
Form1.Caption = "无标题-记事本"
filename = "无标题-记事本"
End If
If Flag = vbCancel Then Exit Sub
If Flag = vbNo Then
RichText.Text = ""
Form1.Caption = "无标题-记事本"
filename = "无标题-记事本"
End If
End If
End If
End Sub

Private Sub mnuopen_Click()
msgtext = "文件" & filename & "的文字已经改变。" & Chr(10) & Chr(13) & "想保存文件吗?"
On Error Resume Next
If ask = True Then
Flag = MsgBox(msgtext, 35, "记事本") '给予提示
If Flag = vbYes Then mnusave_Click '选择了确定则保存之
If Flag = vbCancel Then Exit Sub
If Flag = vbNo Then GoTo L1
End If
ask = False

L1: CommonDialog1.Filter = "文本文档(*.txt)|*.txt|RTF文档(*.rtf)|*.rtf|所有文件(*.*)|*.*"
CommonDialog1.ShowOpen
RichText.Text = "" '清空文本框
filename = CommonDialog1.filename
RichText.LoadFile filename
result = GetFileTitle(filename)
Me.Caption = "" & result & "-记事本"

End Sub

Private Sub mnupagesetup_Click()
psdlg.lStructSize = Len(psdlg)
psdlg.hwndOwner = hwnd
PageSetupDlg psdlg
End Sub

Private Sub mnuplaster_Click()
RichText.SelText = Clipboard.GetText(1)
End Sub

Private Sub mnuprint_Click()
Dim f As Integer, t As Integer
Dim i As Integer
CommonDialog1.CancelError = True
CommonDialog1.Max = 1000
CommonDialog1.Min = 1
On Error Resume Next
CommonDialog1.ShowPrinter

For f = CommonDialog1.FromPage To t = CommonDialog1.ToPage
Do While i < CommonDialog1.Copies + 1
Printer.Print RichText.Text
i = i + 1
Loop
Next
Printer.EndDoc
Cancel:
If Err.Number = 32755 Then
Exit Sub
End If
End Sub

Private Sub mnusave_Click()
CommonDialog1.Filter = "文本文档(*.txt)|所有文件(*.*)|*.*"
On Error Resume Next
filename = CommonDialog1.filename '保存文件
If filename <> "" Then
RichText.SaveFile filename, rtfText
Else
mnusaveas_Click
End If
ask = False
End Sub

Private Sub mnusaveas_Click()
CommonDialog1.Filter = "文本文档(*.txt)|所有文件(*.*)|*.*"
On Error Resume Next

CommonDialog1.ShowSave
filename = CommonDialog1.filename
RichText.SaveFile filename, rtfText

result = GetFileTitle(filename)
Me.Caption = "" & result & "-记事本"
ask = False
End Sub

Private Sub mnustatusbar_Click()
If mnustatusbar.Checked Then
StatusBar1.Visible = False
mnustatusbar.Checked = False
Else
StatusBar1.Visible = True
mnustatusbar.Checked = True
End If

End Sub

Private Sub mnutimedate_Click()
RichText.SelText = Format(Now, "h:mm ddddd")
End Sub

Private Sub mnuwordwrap_Click()
WrapTextLine RichText, bWrap
bWrap = Not bWrap
If mnuwordwrap.Checked = False Then
HScroll1.Enabled = True
mnuwordwrap.Checked = True

Else
HScroll1.Enabled = False
mnuwordwrap.Checked = False

End If

End Sub

Private Sub RichText_Change()
ask = True
End Sub

Private Sub Timer1_Timer()
If StatusBar1.Panels(1).Text <> CStr(Time) Then
StatusBar1.Panels(1).Text = Time
End If

End Sub

'模块代码

Option Explicit
Const WM_USER = &H400
Const EM_SETTARGETDEVICE = (WM_USER + 72)
Type POINTAPI
x As Long
y As Long
End Type
Type RECT
left As Long
right As Long
top As Long
bottom As Long
End Type
Public Type PageSetupDlg
lStructSize As Long
hwndOwner As Long
hDevMode As Long
hDevNames As Long
flags As Long
ptPaperSize As POINTAPI
rtMinMargin As RECT
rtMargin As RECT
hInstance As Long
lCustData As Long
lpfnPageSetupHook As Long
lpfnPagePaintHook As Long
lpPageSetupTemplateName As String
hPageSetupTemplate As Long
End Type
Public psdlg As PageSetupDlg
Declare Function PageSetupDlg Lib "comdlg32.dll" Alias "PageSetupDlgA" (pPagesetupdlg As PageSetupDlg) As Long

Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Dim bWrap As Boolean '// 换行标记'// 自定义一个换行的过程
Public Sub WrapTextLine(ByRef RichText As RichTextBox, ByVal bWrapSwitch As Boolean)
On Error Resume Next
If bWrapSwitch Then '// 设置 RichTextBox 自动换行
SendMessage RichText.hwnd, EM_SETTARGETDEVICE, GetDC(RichText.hwnd), RichText.Width / 15
RichText.RightMargin = IIf(RichText.RightMargin = 0, 1, 0)
Else
'// 设置 RichTextBox 不自动换行
SendMessage RichText.hwnd, EM_SETTARGETDEVICE, 0, 1
End If
End Sub
Function GetFileTitle(OldStr As String) As String

On Error Resume Next
Dim n As Integer, m As Integer '声明字符串变量
Dim i As String, r As String
Dim p As Integer
i = "\" '要查找的指定字符
For n = 1 To Len(OldStr) '用Len函数计算已知字符串的字节数
m = InStrRev(OldStr, i, -1) '"\"所在的位置(其中的-1是默认的)
Next n '找下去!

'截取最后一个"\"后面的字符串
r = right(OldStr, Len(OldStr) - m) '获取Title
p = InStrRev(r, ".", -1) '"."所在位置
GetFileTitle = left(r, p - 1) '去掉后缀

End Function
钞琼习幻玉
2019-03-06 · TA获得超过3719个赞
知道小有建树答主
回答量:3219
采纳率:32%
帮助的人:174万
展开全部
请确保commonDialog控件已拖放到form上,具体步骤为:在vb的project菜单下,打开components子菜单,在弹出窗口中的controls标签页下,找到Microsoft
Common
Dialog
?.0(SP?)打上勾后确定,确定之后在控件选择那个栏位表会出现一个新加入的图标,鼠标移上去会出现CommonDialog字样,将它点击拖入你建立的窗体上,再尝试运行
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
禹鸣都寄真
2020-03-28 · TA获得超过3728个赞
知道大有可为答主
回答量:3035
采纳率:28%
帮助的人:268万
展开全部
没有在窗体添加
CommonDialog
控件
Ctrl+T,选择
microsoft
common
dialog..
再在工具箱中将其拖到窗体即可
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
秋色烽火
2008-01-07 · TA获得超过1.2万个赞
知道大有可为答主
回答量:1.5万
采纳率:37%
帮助的人:1.2亿
展开全部
http://download.csdn.net/sort/tag/%E8%AE%B0%E4%BA%8B%E6%9C%AC%EF%BC%8Cvb%EF%BC%8C%E6%BA%90%E4%BB%A3%E7%A0%81

CSDN的下载 需要先注册会员 我下载过 基本实现记事本的需求
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
sihai163
2008-01-07 · TA获得超过160个赞
知道小有建树答主
回答量:469
采纳率:0%
帮助的人:377万
展开全部
以前做过.并不难实现,VB有个控件rich textbox,记事本的基本功能都能用它实现
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(4)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式