I need to have my button disabled while dzien=0, and enabled while dzien >0.
When I launch the application, it doesn’t matter if day is 0 or 102938129038, button is still disabled. What’s wrong with my code?
Imports System.IO.IsolatedStorage
Partial Public Class Page1
Inherits PhoneApplicationPage
Private dzien As Integer
Public Sub New()
InitializeComponent()
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
IsolatedStorageSettings.ApplicationSettings("dzien") = dzien
Try
dzien = CInt(IsolatedStorageSettings.ApplicationSettings("dzien"))
Catch ex As KeyNotFoundException
dzien = 0
End Try
If dzien = 0 Then
dzien = dzien + 1
End If
NavigationService.Navigate(New Uri("/2.xaml", UriKind.Relative))
End Sub
Private Sub Class_1_loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
If dzien = 0 Then
Button2.IsEnabled = False
Else
Button2.IsEnabled = True
End If
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button2.Click
dzien = dzien + 1
NavigationService.Navigate(New Uri("/2.xaml", UriKind.Relative))
End Sub
End Class
I’m not sure if
If dzien = 0 Then
dzien = dzien + 1
End If
works well
and
dzien = dzien + 1
1 Answer