把代碼寫在FormClosing事件中。
專注于為中小企業(yè)提供成都網(wǎng)站建設(shè)、網(wǎng)站制作服務(wù),電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)奉賢免費做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了1000+企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實現(xiàn)規(guī)模擴充和轉(zhuǎn)變。
如果不想關(guān)閉窗體,則使用e.Cancel = True
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
SaveSetting("appname", "Startup", "text1", TextBox1.Text)
SaveSetting("appname", "Startup", "text2", TextBox2.Text)
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim text1 As Double
Dim text2 As Double
text1 = GetSetting("appname", "startup", "text1", 8)
text2 = GetSetting("appname", "Startup", "text2", 6)
TextBox1.Text = text1
TextBox2.Text = text2
End Sub
只需要用變量存儲 Image 對象,然后不需要的時候釋放掉就行了。
Dim img1 As Image
img1 = Image.FromFile(pic)
PictureBox1.Image = img1
'窗口關(guān)閉時
img1 = Nothing
如滿意,請采納。