vb.net案例源代码 vb的源代码( 二 )


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

推荐阅读