求一个用VB做的简单文本编辑器

来自:    更新日期:早些时候
如何用java编写一个简单的文本编辑器?~

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;

public class f1 extends Frame implements ActionListener
{
private MenuBar menubar=new MenuBar();
private Menu filemenu=new Menu("文件");
private Menu editmenu=new Menu("编辑");
private Menu formmenu=new Menu("格式");
private MenuItem[] itemf=new MenuItem[4];
private MenuItem[] iteme=new MenuItem[6];
private MenuItem[] items=new MenuItem[2];
private TextArea tf=new TextArea();

public int a=0,b=0,c=0,style=Font.PLAIN,size=15;
public String s1="red:"+a+" "+"green:"+b+" "+"blue"+c,
s2="宋体";

public String[] sz1={"10","16","24","30","32","36"},
sz2={"宋体","黑体","幼圆","隶书","行楷","Arial","Georgia"},
sz3={"粗体","倾斜","常规","粗斜"};

JDialog dialog=new JDialog(this,"字体",true);
Container cp=dialog.getContentPane();
JLabel[] lb=new JLabel[8];
JLabel lb1=new JLabel(s1,JLabel.LEFT);
JButton b1=new JButton("确定"),
b2=new JButton("取消");
JComboBox jc1=new JComboBox(),
jc2=new JComboBox(),
jc3=new JComboBox();
JScrollBar jb1=new JScrollBar(JScrollBar.HORIZONTAL,10,5,0,260);
JScrollBar jb2=new JScrollBar(JScrollBar.HORIZONTAL,10,5,0,260);
JScrollBar jb3=new JScrollBar(JScrollBar.HORIZONTAL,10,5,0,260);

哦 看错了 sorry

你告诉一下邮箱 我发给你

Private Sub Form_Load()
' Change the working directory to the directory where this application is located.
ChDir App.Path
ChDrive App.Path

' Position the text box.
txtEdit.Move 0, tlbToolbar.Height

' The form is horizontally and vertically centered when loaded.
Top = Screen.Height / 2 - Height / 2
Left = Screen.Width / 2 - Width / 2
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
' The general procedure DoUnLoadPreCheck handles the possible unload options
' for all three forms in this sample application.
DoUnLoadPreCheck UnloadMode
End Sub

Private Sub Form_Resize()
txtEdit.Width = ScaleWidth
txtEdit.Height = ScaleHeight - tlbToolbar.Height
End Sub

Private Sub mnuAbout_Click()
' display the About form with Show method
frmAbout.Show 1
End Sub

Private Sub mnuBackColorItem_Click(Index As Integer)
Select Case Index
Case 0 ' Set BackColor to Red
txtEdit.BackColor = RGB(255, 0, 0)
Case 1 ' Set BackColor to Green
txtEdit.BackColor = RGB(0, 255, 0)
Case 2 ' Set BackColor to Blue
txtEdit.BackColor = RGB(0, 0, 255)
End Select
End Sub

Private Sub mnuBlueItem_Click(Index As Integer)
' If the user chooses Light Blue, then set the Forecolor to light
' blue, otherwise do nothing.
If Index = 0 Then
txtEdit.ForeColor = RGB(0, 150, 255)
End If
End Sub

Private Sub mnuDarkBlueItem_Click(Index As Integer)
Select Case Index
Case 0
' Set ForeColor to Sea Blue.
txtEdit.ForeColor = RGB(0, 50, 175)
Case 1
' Set ForeColor to Midnight Blue.
txtEdit.ForeColor = RGB(0, 0, 255)
End Select
End Sub

Private Sub mnuEdit_Click()
' Disable Cut and Copy if no text selected.
mnuEditItem(0).Enabled = (txtEdit.SelLength > 0)
mnuEditItem(1).Enabled = (txtEdit.SelLength > 0)
End Sub

Private Sub mnuEditItem_Click(Index As Integer)
Select Case Index
Case 0
' If Index = 0, user chose Cut.
Clipboard.Clear
Clipboard.SetText txtEdit.SelText ' Copy selected text onto the Clipboard.
txtEdit.SelText = "" ' Clear selected text from the document.
Case 1
' If Index = 1, user chose Copy.
Clipboard.Clear
Clipboard.SetText txtEdit.SelText ' Copy selected text onto Clipboard.
Case 2
' If Index = 2, user chose Paste.
txtEdit.SelText = Clipboard.GetText() ' Paste Clipboard text (if any) into document.
End Select
End Sub

Private Sub mnuFileArray_Click(Index As Integer)
' Open the selected file.
If Index >= 0 Then
OpenFile (mnuFileArray(Index).Caption)
End If
End Sub

Private Sub mnuFileItem_Click(Index As Integer)

' CancelError is True
On Error GoTo errhandler

Select Case Index
' Check index value of selected menu item.
Case 0
' If index = 0, the user chose New.
txtEdit.Text = "" ' Clear the text box.
Filename = "Untitled" ' Set the title bar caption to "Text Editor: Untitled"
frmEditor.Caption = "Text Editor: " & Filename
Case 1
' If index = 1, the user chose Open.
' Set filters.
CMDialog1.Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|Batch Files (*.bat)|*.bat"
' Specify default filter.
CMDialog1.FilterIndex = 2
' Display the File Open dialog box.
CMDialog1.ShowOpen
Filename = CMDialog1.Filename
OpenFile (Filename)
Case 2
' If index = 2, the user chose Save As.
' Set filters.
CMDialog1.Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|Batch Files (*.bat)|*.bat"
' Specify default filter.
CMDialog1.FilterIndex = 2
' Display the Save As dialog box.
CMDialog1.ShowSave
Filename = CMDialog1.Filename
CloseFile (Filename)
Case 3
' This menu item is a separator bar, no code needs to be written here
' because it cannot be selected and therefore cannot receive a Click event.
Case 4
' If index = 4, the user chose Exit.
End ' End this application and return to the Windows operating system.
End Select
errhandler:
' The user clicked the Cancel button.
Exit Sub
End Sub

Private Sub mnuFontSizesItem_Click(Index As Integer)
Select Case Index
' Perform an action based on the Index property value of menu control.
Case 0
' If Index = 0, then the user chose font size 12.
txtEdit.FontSize = 12 ' Set the FontSize property of the text box to 12.
mnuFontSizesItem(0).Checked = True ' Display a check mark next to 12.
mnuFontSizesItem(1).Checked = False ' Remove the check mark next to 24.
Case 1
txtEdit.FontSize = 24 ' Set the FontSize property of the text box to 24.
mnuFontSizesItem(0).Checked = False ' Remove the check mark next to 12.
mnuFontSizesItem(1).Checked = True ' Display a check mark next to 24.
End Select
' Display the font size next to the Font Size command.
mnuSettingsItem(1).Caption = Left$(mnuSettingsItem(1).Caption, 10) & " " & mnuFontSizesItem(Index).Caption
End Sub

Private Sub mnuForeColorItem_Click(Index As Integer)
Select Case Index
Case 0
' Set ForeColor to Red
txtEdit.ForeColor = RGB(255, 0, 0)
Case 1
' Set ForeColor to Green
txtEdit.ForeColor = RGB(0, 255, 0)
Case 2
' No code for this case because submenu is automatically displayed in Case 2.
End Select
End Sub

Private Sub tlbToolbar_ButtonClick(ByVal Button As Button)
' CancelError is True
On Error GoTo errhandler

Select Case Button.Key
Case "New" 'New Button Check
txtEdit.Text = "" ' Clear the text box.
Filename = "Untitled" ' Set the title bar caption to "Text Editor: Untitled"
frmEditor.Caption = "Text Editor: " & Filename
Case "Open" 'Open Button Check
' Set filters.
CMDialog1.Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|Batch Files (*.bat)|*.bat"
CMDialog1.FilterIndex = 2 ' Specify default filter.
CMDialog1.ShowOpen ' Display the File Open dialog box.
Filename = CMDialog1.Filename
OpenFile (Filename)
Case "SaveAs" 'Save As Button Check
' Set filters.
CMDialog1.Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|Batch Files (*.bat)|*.bat"
CMDialog1.FilterIndex = 2 ' Specify default filter.
CMDialog1.ShowSave ' Display the Save As dialog box.
Filename = CMDialog1.Filename
CloseFile (Filename)
Case "Copy" 'Copy Button Check
Clipboard.Clear
Clipboard.SetText txtEdit.SelText ' Copy selected text onto Clipboard.
Case "Cut" 'Cut Button Check
Clipboard.Clear
Clipboard.SetText txtEdit.SelText ' Copy selected text onto the Clipboard.
txtEdit.SelText = "" ' Clear selected text from the document.
Case "Paste" 'Paste Button Check
txtEdit.SelText = Clipboard.GetText() ' Paste Clipboard text (if any) into document.
Case "Bold" 'Bold Button Image Check
txtEdit.Font.Bold = Not txtEdit.Font.Bold
Case "Underline" 'Cut Button Check
txtEdit.Font.Underline = Not txtEdit.Font.Underline
Case "Italics" 'Paste Button Check
txtEdit.Font.Italic = Not txtEdit.Font.Italic
End Select

errhandler:
' The user clicked the Cancel button.
Exit Sub
End Sub

你好,我叫candy,我已经把程序发送到你的邮箱了

若使用中有不明白或出错的地方,欢迎你随时提问

发给你了,[email protected]

不就是一个文本框嘛


求一个用VB做的简单文本编辑器视频

相关评论:
  • 15841788436用VB编辑记事本文件内的数据
    郟贪民Dim a() As String '声明一个数组 Private Sub Command1_Click() '交换按钮 Dim temp As String '临时变量 a = Split(Text1.text, ",") '将Text1中内容按逗号切分后存入数组a,a现在有4个元素,分别是Text1中的四个数据 temp = a(1): a(1) = a(2): a(2) = temp '交换x和y ...

  • 15841788436vb求教文本指定行替换数值问题
    郟贪民如果你的文本中的行分隔符不同(比如只是简单的换行符`vbLf`或者你使用了其他方式来标识行的结束),你需要对上面的代码进行相应的修改。要实现这个目标,您可以使用Python的内置文件读写功能。以下是一个简单的例子来展示如何做到这一点。请注意,您需要提前安装xml.etree.ElementTree模块,这是Python自带的...

  • 15841788436求一个VB做的文本编辑器 用副文本框做的
    郟贪民已经发到你邮箱里了...这是很久以前做的,代码可能会有一些错误和不妥,还请原谅...

  • 15841788436我看见你用VB编辑文本字体那个回答,请问具体怎么进行?谢谢
    郟贪民加我百度HI吧,我告诉你怎么做,下面是例子 '建立一个窗体,添加1个按钮一个文本框和一个commondialog控件,名称都选默认 Private Sub Command1_Click()CommonDialog1.CancelError = True CommonDialog1.Flags = cdlCFBoth + cdlCFPrinterFonts On Error GoTo Ers CommonDialog1.ShowFont On Error ...

  • 15841788436如何用vb创建任意内容的文本文档
    郟贪民RichTextBox控件 允许用户输入和编辑文本的同时提供了比普通的TextBox控件更高级的格式特征。 RichTextBox控件提供了数个有用的特征,你可以在控件中安排文本的格式。

  • 15841788436VB简易程序设计代码
    郟贪民题目一:Private Sub Text1_Change()Text2.Text = Text1.Text End Sub 题目二:Private Sub Command1_Click()Text1.Text = "程序设计第一步:设计界面"End Sub Private Sub Command2_Click()Text1.Text = "程序设计第二步:属性设置"End Sub Private Sub Command3_Click()Text1.Text = "...

  • 15841788436VB大作业,一个文本编辑器,需要利用组合框来设置字体的类型大小颜色等...
    郟贪民如图。。。

  • 15841788436毕业设计要用vb作一个程序 本人vb新手 希望有vb大侠能帮帮忙 指导我一...
    郟贪民用VB制作一个简单记事本问题! 比如我定义如下控件: text文件控件名字:a_txt 对话框控件名字:cmd_dlg 一个按扭名字:cmd_open 我想实现这样的一个功能,单击cmd_open就弹出一个对话框,然后选择一个文本文件(*.txt)。打开,就会在a_txt这个控件上边显示文本文件内容,应该怎么样做呢?我不太懂VB,请各位朋友帮我完成...

  • 15841788436用VB编个输入密码程序(简单点的)
    郟贪民新建工程---添加一个commandbuton控件~双击窗体进入代码编辑区~复制一下代码 Private Sub Command1_click()Const Pwd = "123456" '改成密码 x = InputBox("内容", "标题", "输入栏内容")If x = Pwd Then MsgBox "密码正确"Else MsgBox "密码错误"End If end sub 按f5运行 点击按钮 看到...

  • 15841788436VB中Texe文本框如何编辑让其必须输入一个数值,否则跳出MsgBox提示并回 ...
    郟贪民用Keypress()方法,不要用Change()方法 因为如果是change事件的话在TEXT中输入一个值然后print text就会显示出来 但是keypress事件在TEXT中输入一个值然后print text却显示不出来 Private Sub txtText1_KeyPress(KeyAscii As Integer)If KeyAscii < 48 And KeyAscii > 57 Then MsgBox "aaaa"txtText1....

  • 相关主题精彩

    版权声明:本网站为非赢利性站点,内容来自于网络投稿和网络,若有相关事宜,请联系管理员

    Copyright © 喜物网