大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
这个有个笨方法:
创新互联公司专业为企业提供福建网站建设、福建做网站、福建网站设计、福建网站制作等企业网站建设、网页设计与制作、福建企业网站模板建站服务,十年福建做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
private
sub
command2_click()
select
case
text1.text
case
"form1"
form1.show
case
"form2"
form2.show
case
else
mgsbox
"没有这个窗体名"
end
select
end
sub
前提是把所有关的窗体名都要知道
呵呵
this.close() 只是关掉,没有释放,不对 me.close() 应该释放一下 me.Dispose() 给分吧、
1、如果上一个窗体是程序的主窗体(默认是程序的第一个窗体),
则不能关闭这个窗体,只能隐藏(Me.Hide())这个窗体,否则整
个程序就被关掉了。
2、如果上一个窗体不是程序的主窗体,可以用Me.Close()
关闭。
Private Sub frmNotepad_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Call subexit()
End
End Sub
Sub subexit()
Dim frmNew As frmNotepad
frmNew = ActiveForm
If frmNew.Text = "未定标题 - 记事本" Then
If frmNew.rtb.Text = "" Then
Else
Dim result As New MsgBoxResult 'result提示对话框yes,no,cancel
result = MsgBox("未定标题 文件的文字已经改变。" Chr(10) Chr(10) "想保存文件吗?", MsgBoxStyle.YesNoCancel + MsgBoxStyle.Exclamation, "记事本")
If result = MsgBoxResult.Yes Then 'result.Yes表示保存,清空内容,打开新页面
Dim fileSave As New SaveFileDialog
Dim re As New DialogResult 're提示对话框OK,cancel
fileSave.FileName = "*.txt"
fileSave.Filter = "文本文档(*.txt)|*.txt|所有文件|*.*"
re = fileSave.ShowDialog()
If re = DialogResult.OK Then 're.OK表示成功保存,清空内容,打开新页面
filename = fileSave.FileName
Dim fstream As FileStream
Dim sw As StreamWriter
Try
'frmNew.Text = filename.Substring(filename.LastIndexOf("\") + 1) "- 记事本"
fstream = New FileStream(filename, FileMode.Create, FileAccess.ReadWrite)
sw = New StreamWriter(fstream, System.Text.Encoding.Default)
sw.BaseStream.Seek(0, SeekOrigin.End)
sw.Write(rtb.Text)
sw.Flush()
Catch ex As Exception
MsgBox("保存文件失败")
Finally
sw.Close()
End Try
ElseIf re = DialogResult.Cancel Then 're.cancel表示不保存,不改变任何结果
End If
ElseIf result = MsgBoxResult.No Then 'result.no表示不保存,清空内容
rtb.Text = ""
End If
End If
Else
If rtb.Text.Compare(rtb.Text, compareStr) 0 Then
Dim result As New MsgBoxResult
result = MsgBox(filename + " 文件的文字已经改变。" Chr(10) Chr(10) "想保存文件吗?", MsgBoxStyle.YesNoCancel + MsgBoxStyle.Exclamation, "记事本")
If result = MsgBoxResult.Yes Then
Dim fstream As FileStream
Dim sw As StreamWriter
Try
'frmNew.Text = filename.Substring(filename.LastIndexOf("\") + 1) "- 记事本"
fstream = New FileStream(filename, FileMode.Create, FileAccess.ReadWrite)
sw = New StreamWriter(fstream, System.Text.Encoding.Default)
sw.BaseStream.Seek(0, SeekOrigin.End)
sw.Write(rtb.Text)
sw.Flush()
Catch ex As Exception
MsgBox("保存文件失败")
Finally
sw.Close()
End Try
ElseIf result = MsgBoxResult.No Then
rtb.Text = ""
End If
End If
End If
End Sub