当我想按下按钮时,它会给我错误“找不到密钥”。我想要变量“dzien”的默认值 = 0。
Imports System.IO.IsolatedStorage
Partial Public Class _1
Inherits PhoneApplicationPage
Private dzien As Integer
Public Sub New()
InitializeComponent()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button2.Click
dzien = CInt(IsolatedStorageSettings.ApplicationSettings("dzien"))
Try
dzien = CInt(IsolatedStorageSettings.ApplicationSettings("dzien"))
Catch ex As KeyNotFoundException
dzien = 0
End Try
If dzien = 0 Then
TextBox1.Text += "dzien jest 0 !"
End If
End Sub
Private Sub Class_1_Unloaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Unloaded
IsolatedStorageSettings.ApplicationSettings("dzien") = dzien
End Sub
结束类