网站建设资讯

NEWS

网站建设资讯

关于vb点虐 记事本源代码的信息

VB.NET做一个类似记事本的可执行文件,保存时不知道怎么用代码设置保存类型(文件扩展名)

算了,都贴上,你自己看吧:

创新互联是专业的邕宁网站建设公司,邕宁接单;提供成都网站制作、成都网站建设,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行邕宁网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

//设置文件类型

//书写规则例如:txt files(*.txt)|*.txt

saveFileDialog.Filter = "txt files(*.txt)|*.txt|xls files(*.xls)|*.xls|All files(*.*)|*.*"

//设置默认文件名(可以不设置)

saveFileDialog.FileName = "siling-Data"

//主设置默认文件extension(可以不设置)

saveFileDialog.DefaultExt = "xml"

//获取或设置一个值,该值指示如果用户省略扩展名,文件对话框是否自动在文件名中添加扩展名。(可以不设置)

saveFileDialog.AddExtension = true

//设置默认文件类型显示顺序(可以不设置)

saveFileDialog.FilterIndex = 2

//保存对话框是否记忆上次打开的目录

saveFileDialog.RestoreDirectory = true

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

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

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

然后用一个调用代码:

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

这是要开记事本的

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

这是打开计算器的

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

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

VB编写记事本

vb编写的简单记事本代码

Dim b As String

Dim a As String

Dim m As String

Dim x As String

Private Declare Function SetWindowPos Lib "user32" ( _

ByVal hwnd As Long, _

ByVal hWndInsertAfter As Long, _

ByVal x As Long, ByVal Y As Long, _

ByVal cx As Long, ByVal cy As Long, _

ByVal wFlags As Long _

) As Long

Const HWND_TOPMOST = -1

Const SWP_SHOWWINDOW = H40

Private Sub baocun_Click()

Dim abc As String

If Len(Trim(m)) = 0 Then

m = "f:"

End If

abc = m "\" Text2.Text ".txt"

Open abc For Output As #1

Write #1, Text1.Text

Close #1

Label2.Caption = "保存的路径为:" m "\" Text2.Text ".txt"

a = MsgBox("保存成功!" Chr(13) "是否退出程序", 4 + 64 + 0, "提示")

If a = vbYes Then

End

End If

End Sub

Private Sub Command1_Click()

Dir1.Visible = False

Drive1.Visible = False

m = Dir1.Path

Command1.Visible = False

b = MsgBox("你选的文件夹是:" m, vbYesNo + vbDefaultButton1 + 48, "提示")

If b = vbNo Then

Dir1.Visible = True

Drive1.Visible = True

Command1.Visible = True

Else

Dir1.Visible = False

Drive1.Visible = False

Command1.Visible = False

End If

End Sub

Private Sub Command2_Click()

MsgBox (App.Path + "1.ico")

End Sub

Private Sub dakai_Click()

CommonDialog1.Filter = "文本文件(*.txt)|*.txt"

CommonDialog1.ShowOpen

Open CommonDialog1.FileName For Input As #1

Dim abc As String

linefromfile = StrConv(InputB(LOF(1), 1), vbUnicode)

Text1.Text = linefromfile

Close #1

End Sub

Private Sub Drive1_Change()

Dir1.Path = Drive1.Drive

End Sub

Private Sub Form_Load()

Drive1.Drive = "f:\"

Dir1.Visible = False

Drive1.Visible = False

Command1.Visible = False

Dim fullpath As String

If Right(App.Path, 1) = "\" Then

fullpath = App.Path + "1.ico"

Else

fullpath = App.Path + "\" + "1.ico"

Form1.Icon = LoadPicture(fullpath)

End If

End Sub

Private Sub lingcunwei_Click()

Dim abc As String

CommonDialog1.ShowSave

If Len(Trim(CommonDialog1.FileName)) 0 Then

x = CommonDialog1.FileName

Else

x = "f:\1.txt"

End If

Open x For Append As #1

Write #1, Text1.Text

Close #1

End Sub

Private Sub s_Click()

Text1.FontSize = 5

End Sub

Private Sub sanhao_Click()

Text1.FontSize = 12

End Sub

Private Sub st_Click()

CommonDialog1.ShowFont

End Sub

Private Sub shybcdwjj_Click()

Dir1.Visible = True

Drive1.Visible = True

Command1.Visible = True

End Sub

Private Sub Text2_GotFocus()

Dir1.Visible = False

Drive1.Visible = False

Command1.Visible = False

End Sub

Private Sub tuichu_Click()

End

End Sub

Private Sub wh_Click()

Text1.FontSize = 10

End Sub

Private Sub whs_Click()

Text1.FontSize = 10.5

End Sub

Private Sub xinjian_Click()

Text1.Text = ""

Text2.Text = ""

End Sub

Private Sub yh_Click()

Text1.FontSize = 24

End Sub

Private Sub zstj_Click()

MsgBox "所有字数为" Len(Text1.Text), , " 字数"

End Sub

Private Sub ztys_Click()

CommonDialog1.ShowColor

Text1.ForeColor = CommonDialog1.Color

End Sub

Private Sub zzqm_Click()

Dim retValue As Long

'将窗体设置为处于所有窗口的顶层,注意在 VB 中运行时,可能不行,但编译成EXE后就可以了

retValue = SetWindowPos(Me.hwnd, HWND_TOPMOST, Me.CurrentX, Me.CurrentY, 380, 615, SWP_SHOWWINDOW)

End Sub

求VB.NET记事本“保存”按钮代码

Dim WithEvents SvaeFileDialog1 As New SaveFileDialog

Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles button1.Click

Dim pp As String

SvaeFileDialog1.Filter = "文档文件(*.txt)|*.txt|所有文件(*.*)|*.*"

Dim r As MsgBoxResult

r = SvaeFileDialog1.ShowDialog

If r Then

FileOpen(1, SvaeFileDialog1.FileName, OpenMode.Output)

pp = Mid(Me.TextBox1.Text, 1, Len(Me.TextBox1.Text))

Print(1, pp)

Close()

MsgBox("Export Successfully!")

End If

End Sub

以上VS2010 WPF程序。


本文名称:关于vb点虐 记事本源代码的信息
本文路径:http://njwzjz.com/article/ddjighc.html