https://i.stack.imgur.com/ZxpaP.png
‘InitializeComponent’ is not declared. It may be inaccessible due to its protection level.
https://i.stack.imgur.com/na20Z.png
‘CountTextBlock’ is not a member of ‘Tally.Tally.MainPage’.
I have no idea why i am getting these errors. Please check the links for images of the errors. I have converted the code from c# to Vb.net using many converters. All of them gives the same conversion.
Code :-
Imports System.Windows
Imports System.Windows.Input
Imports System.Windows.Navigation
Imports Microsoft.Phone.Controls
Imports Tally.WindowsPhoneApp ' For the Setting class
Namespace Tally
Partial Public Class MainPage
Inherits PhoneApplicationPage
Private count As Integer = 0
' Remember what the user typed, for future app activations or launches:
Private savedCount As New Setting(Of Integer)("SavedCount", 0)
Public Sub New()
InitializeComponent()
End Sub
' Handle a tap anywhere on the page (other than the Button)
Protected Overrides Sub OnMouseLeftButtonDown(ByVal e As MouseButtonEventArgs)
MyBase.OnMouseLeftButtonDown(e)
Me.count += 1
Me.CountTextBlock.Text = Me.count.ToString("N0")
End Sub
' Handle a tap on the button
Private Sub ResetButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Me.count = 0
Me.CountTextBlock.Text = Me.count.ToString("N0")
End Sub
Protected Overrides Sub OnNavigatedFrom(ByVal e As NavigationEventArgs)
MyBase.OnNavigatedFrom(e)
' Persist state when leaving for any reason (Deactivated or Closing):
Me.savedCount.Value = Me.count
End Sub
Protected Overrides Sub OnNavigatedTo(ByVal e As NavigationEventArgs)
MyBase.OnNavigatedTo(e)
' Restore persisted state:
Me.count = Me.savedCount.Value
Me.CountTextBlock.Text = Me.count.ToString("N0")
End Sub
End Class
End Namespace
Settings.vb
Imports System.IO.IsolatedStorage
Namespace WindowsPhoneApp
' Encapsulates a key/value pair stored in Isolated Storage ApplicationSettings
Public Class Setting(Of T)
Private name As String
'INSTANT VB NOTE: The variable value was renamed since Visual Basic does not allow class members with the same name:
Private value_Renamed As T
'INSTANT VB NOTE: The variable defaultValue was renamed since Visual Basic does not allow class members with the same name:
Private defaultValue_Renamed As T
Private hasValue As Boolean
Public Sub New(ByVal name As String, ByVal defaultValue As T)
Me.name = name
Me.defaultValue_Renamed = defaultValue
End Sub
Public Property Value() As T
Get
' Check for the cached value
If Not Me.hasValue Then
' Try to get the value from Isolated Storage
If Not IsolatedStorageSettings.ApplicationSettings.TryGetValue(Me.name, Me.value_Renamed) Then
' It hasn’t been set yet
Me.value_Renamed = Me.defaultValue_Renamed
IsolatedStorageSettings.ApplicationSettings(Me.name) = Me.value_Renamed
End If
Me.hasValue = True
End If
Return Me.value_Renamed
End Get
Set(ByVal value As T)
' Save the value to Isolated Storage
IsolatedStorageSettings.ApplicationSettings(Me.name) = value
Me.value_Renamed = value
Me.hasValue = True
End Set
End Property
Public ReadOnly Property DefaultValue() As T
Get
Return Me.defaultValue_Renamed
End Get
End Property
' "Clear" cached value:
Public Sub ForceRefresh()
Me.hasValue = False
End Sub
End Class
End Namespace
Try creating new pages in your project first via the built-in Visual Studio facilities, then copy and paste your translated code on top of the auto-generated code.
I believe the problem is that you’re missing the rest of the
.designer.vbcode files that are normally auto-generated when you’re creating these pages by hand.