Private Sub frmNotepad_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
10年積累的成都網(wǎng)站建設(shè)、網(wǎng)站制作經(jīng)驗(yàn),可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識你,你也不認(rèn)識我。但先網(wǎng)站設(shè)計(jì)后付款的網(wǎng)站建設(shè)流程,更有奉新免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
Call subexit()
End
End Sub
Sub subexit()
Dim frmNew As frmNotepad
frmNew = ActiveForm
If frmNew.Text = "未定標(biāo)題 - 記事本" Then
If frmNew.rtb.Text = "" Then
Else
Dim result As New MsgBoxResult 'result提示對話框yes,no,cancel
result = MsgBox("未定標(biāo)題 文件的文字已經(jīng)改變。" Chr(10) Chr(10) "想保存文件嗎?", MsgBoxStyle.YesNoCancel + MsgBoxStyle.Exclamation, "記事本")
If result = MsgBoxResult.Yes Then 'result.Yes表示保存,清空內(nèi)容,打開新頁面
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表示成功保存,清空內(nèi)容,打開新頁面
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表示不保存,不改變?nèi)魏谓Y(jié)果
End If
ElseIf result = MsgBoxResult.No Then 'result.no表示不保存,清空內(nèi)容
rtb.Text = ""
End If
End If
Else
If rtb.Text.Compare(rtb.Text, compareStr) 0 Then
Dim result As New MsgBoxResult
result = MsgBox(filename + " 文件的文字已經(jīng)改變。" 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
VB.NET關(guān)閉當(dāng)前窗體me.close()
其它窗體用:窗體名.close(),例如:form2.close()
me.dispose()
樓主針對這個(gè)問題我也糾結(jié)過很久不過就在剛剛我找到了問題所在:
還是用me.close()
打開
項(xiàng)目
》
最下面一行有一個(gè)屬性》
應(yīng)用程序》下面
有一個(gè)關(guān)機(jī)模式
改為:當(dāng)最后一個(gè)窗體關(guān)閉時(shí)。。。注意
me.close要寫在窗體show()后面
例如
寫成
f2.show()
me.close()
不要寫成
me.close()
f2.show()
兼容ie和firefox js關(guān)閉代碼
script language="javascript" type="text/javascript"
function closeWindow() {
window.open('','_parent','');
window.close();
}
/script
a href="javascript:closeWindow();"Close Window/a
好多朋友用到是自動(dòng)關(guān)閉頁面代碼
script language="javascript"
function closeWindow(){
window.open('','_parent','');
window.close();
}
setTimeout("closeWindow()",3000);
/script
文章題目:vb.net關(guān)閉頁面 vbs關(guān)閉當(dāng)前窗口
當(dāng)前網(wǎng)址:http://chinadenli.net/article34/hgdpse.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃、外貿(mào)建站、網(wǎng)站維護(hù)、微信公眾號、Google、搜索引擎優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)