How to get the Subroutine Sender name - wpf

When I click the Button1 the MsgBox shows me "1" which is good.
Private Sub Button1_Click(sender As Object, e As RoutedEventArgs) Handles Button1.Click
MsgBox(CType(sender, Button).Name.Replace("Button", ""))
End Sub
I want the MsgBox shows me "30" when I click the Button2.
Private Sub Button2_Click(sender As Object, e As RoutedEventArgs) Handles Button2.Click
Hello30()
End Sub
Sub Hello30()
'The following line is need to be repaired.
MsgBox(CType(sender, ????).Name.Replace("Hello", ""))
End Sub

Not really sure what you're trying to do, but this is an example that'll get you close:
Imports System.Reflection
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Hello30()
End Sub
Sub Hello30()
Dim method As String = MethodBase.GetCurrentMethod.Name
MsgBox(method.Replace("Hello", ""))
End Sub

Related

Visual Basic 2013 How to Ping all IPs in ListBox

Hello this is my first time posting here. well to the point, I have pieced together
a app that is able to load a text file, add on the fly to a "listbox", now all i need it to Ping all ips in said "listbox" but i get an error and stops working. need help to ping all ips.
Private Sub Go_Click(sender As Object, e As EventArgs) Handles Go.Click
If ListBox1.Items.Count <= 0 Then
MsgBox("Please Add at Least One IP or Website!")
Exit Sub
End If
For l_index As Integer = 0 To ListBox1.Items.Count - 1 'THIS IS WHERE CODE STOPS WORKING, NEED "MAGIC CODE" HERE
Dim lines As String = CStr(ListBox1.Items(l_index))
BackgroundWorker1.RunWorkerAsync(lines)
Next
End Sub
I am using Openfiledialog to load Text File to listbox1 and backgroundworker to do the ping. I am using
Imports System.Net
Imports System.Net.NetworkInformation
Imports System.Threading
Imports System.IO
What i want to do is once that all "IPs" are in the listbox i want to press Go to Ping all Ips. How can i get this to work?
Imports System.Net
Imports System.Net.NetworkInformation
Imports System.Threading
Imports System.IO
Public Class Main
Private Sub AboutUpingToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AboutUpingToolStripMenuItem.Click
AboutUping.Show()
End Sub
Private Sub MenuStrip1_ItemClicked(sender As Object, e As ToolStripItemClickedEventArgs) Handles MainMenu.ItemClicked
End Sub
Private Sub QuitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles QuitToolStripMenuItem.Click
Application.Exit()
End Sub
Private Sub OpenFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
Dim lines = File.ReadAllLines(OpenFileDialog1.FileName)
ListBox1.Items.AddRange(lines)
End Sub
Private Sub OpenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles OpenToolStripMenuItem.Click
OpenFileDialog1.ShowDialog()
End Sub
Private Sub NewToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles NewToolStripMenuItem.Click
Create.Show()
End Sub
Private Sub ToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem1.Click
End Sub
Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Go_Click(sender As Object, e As EventArgs) Handles Go.Click
If ListBox1.Items.Count <= 0 Then
MsgBox("Please Add at Least One IP or Website!")
Exit Sub
End If
For l_index As Integer = 0 To ListBox1.Items.Count - 1 'THIS IS WHERE CODE STOPS WORKING, NEED "MAGIC CODE" HERE
Dim lines As String = CStr(ListBox1.Items(l_index))
BackgroundWorker1.RunWorkerAsync(lines)
Next
End Sub
Private Sub CloseFileToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CloseFileToolStripMenuItem.Click
TextBox1.Clear()
ListBox1.Items.Clear()
End Sub
Private Sub cmdADD_Click(sender As Object, e As EventArgs) Handles cmdADD.Click
Dim myitem
myitem = txtADD.Text()
ListBox1.Items.Add(myitem)
txtADD.Clear()
End Sub
Private Sub cmdRemove_Click(sender As Object, e As EventArgs) Handles cmdRemove.Click
For a As Int32 = ListBox1.SelectedItems.Count - 1 To 0 Step -1
For i As Int32 = ListBox1.Items.Count - 1 To 0 Step -1
'-- compare the value of the select item to any given item in the list.
If ListBox1.SelectedItems(a) = ListBox1.Items(i) Then
'-- remove the item by the index we found
ListBox1.Items.RemoveAt(i)
'-- exit the inner for loop
Exit For
End If
Next
Next
End Sub
Private Sub cmdClear_Click(sender As Object, e As EventArgs) Handles cmdClear.Click
ListBox1.Items.Clear()
End Sub
Private Sub HelpToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles HelpToolStripMenuItem.Click
End Sub
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
End Sub
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim lines = DirectCast(e.Argument, String())
Dim Ping As New Ping
Dim replies As New List(Of PingReply)
For Each ip In lines
Dim reply = Ping.Send(ip)
replies.Add(reply)
Next
e.Result = replies
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
Dim sb As New System.Text.StringBuilder
Dim replies = DirectCast(e.Result, List(Of PingReply))
For Each reply In replies
Dim index As Integer
index += 1
sb.Append("Ping ").Append(index).Append(": ").Append(reply.Address).Append(" ").Append(reply.RoundtripTime).Append(" ms")
sb.AppendLine()
Next
TextBox1.Text = sb.ToString
End Sub
End Class
Your error is here
one of your ping fails and results an exception which is returned to the completed event handler and when the handler tries to get the result the TargetInvocationException exception is thrown
solution is to check the error
Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
If e.Error Is Nothing Then
Dim sb As New System.Text.StringBuilder
Dim replies = DirectCast(e.Result, List(Of PingReply))
For Each reply In replies
Dim index As Integer
index += 1
sb.Append("Ping ").Append(index).Append(": ").Append(reply.Address).Append(" ").Append(reply.RoundtripTime).Append(" ms")
sb.AppendLine()
Next
TextBox1.Text = sb.ToString
Else
'error handling
End If
End Sub
additionally you may need to handle the actual error to protect rest of the ping replies otherwise because of 1 failure whole batch of result will be lost
For Each ip As String In lines
Try
Dim reply As PingReply = Ping.Send(ip)
replies.Add(reply)
Catch ex as PingException
'error handling
End Try
Next
Update
another point of error,
For l_index As Integer = 0 To ListBox1.Items.Count - 1
Dim lines As String = CStr(ListBox1.Items(l_index))
BackgroundWorker1.RunWorkerAsync(lines)
Next
since you are passing as single string from the method above and in the method below you are attempting to cast as string array so it fails, change it like this
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim ip = DirectCast(e.Argument, String)
Dim Ping As New Ping
Dim replies As New List(Of PingReply)
Try
Dim reply As PingReply = Ping.Send(ip)
replies.Add(reply)
Catch ex as PingException
'error handling
End Try
e.Result = replies
End Sub
also advised to use Option Strict On to reduce some type checking errors
Thanks!Got it to work! Sending "Listbox1" to array
Private Sub Go_Click(sender As Object, e As EventArgs) Handles Go.Click
Dim lines() As String = ListBox1.Items.OfType(Of String)().ToArray()
BackgroundWorker1.RunWorkerAsync(lines)
End Sub
Now it works app does not crash.

OleDBConnection error

I've been working on a computing project in Visual Basic 2010 and I've encountered a error and I cannot find the problem causing it.
Whenever I try to save to my database I get a error in my OleDBConnection.vb form with the following
This is my Code
Class OleDbConnection
Private _p1 As Object
Sub New(ByVal p1 As Object)
' TODO: Complete member initialization
_p1 = p1
End Sub
Sub Close()
Throw New NotImplementedException
End Sub
Sub Open()
**Throw New NotImplementedException**
End Sub
End Class
my original code for the saving of the project to the database is
Public Class AddClass
Public Shared connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\Sami\Desktop\F454\VB_PrototypeDB.accdb;Persist Security Info=False;"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub DataView()
Throw New NotImplementedException
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Me.Hide()
MMenu.Show()
End Sub
Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
Dim cn As New OleDbConnection(connectionString)
cn.Open()
Dim ClassName As String = TextBox1.Text
Dim Subject As String = ComboBox1.Text()
Dim cmd As New OleDbCommand("INSERT INTO Class (ClassName, Subject) VALUES ('" & ClassName & "', '" & Subject & "') ')", cn)
cmd.ExecuteNonQuery()
cn.Close()
Call MsgBox("Student Has Been Saved", 0, "Student Database")
End Sub
End Class

Overload resolution failed because no accessible 'new' can be called without a narrowing conversion

I have a problem.
I am getting this error:
Overload resolution failed because no accessible 'new' can be called
without a narrowing conversion.
Private Sub bt_hapus_Click(sender As Object, e As EventArgs) Handles bt_hapus.Click
Try
Dim sqlda As New SqlClient.SqlDataAdapter("Delete from tblpasien where No_Rkm_Mds=" & Me.No_Rkm_MdsTextBox.Text, Me.KlinikGigiDataSet)
sqlda.Fill(dbpasien, "tblpasien")
MsgBox("Data telah berhasil dihapus")
bersih()
pasif()
normal()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
All source code :
Public Class frm_pasien
Dim dbpasien As New DataSet
Dim dvpasien As New DataView
Dim tekan As Integer
Dim cari As Integer
Private Sub TblpasienBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles TblpasienBindingNavigatorSaveItem.Click
Me.Validate()
Me.TblpasienBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.KlinikGigiDataSet)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'KlinikGigiDataSet.tblpembayaran' table. You can move, or remove it, as needed.
Me.TblpembayaranTableAdapter.Fill(Me.KlinikGigiDataSet.tblpembayaran)
'TODO: This line of code loads data into the 'KlinikGigiDataSet.tblpasien' table. You can move, or remove it, as needed.
Me.TblpasienTableAdapter.Fill(Me.KlinikGigiDataSet.tblpasien)
End Sub
Private Sub BindingNavigatorDeleteItem_Click(sender As Object, e As EventArgs) Handles BindingNavigatorDeleteItem.Click
End Sub
Private Sub BindingNavigatorAddNewItem_Click(sender As Object, e As EventArgs) Handles BindingNavigatorAddNewItem.Click
End Sub
Private Sub bt_keluar_Click(sender As Object, e As EventArgs) Handles bt_keluar.Click
Dim pesan As DialogResult = MsgBox("Apakah anda yakin akan keluar", MsgBoxStyle.OkCancel)
If pesan = DialogResult.OK Then
Me.Close()
Else
Exit Sub
End If
End Sub
Private Sub bt_hapus_Click(sender As Object, e As EventArgs) Handles bt_hapus.Click
Try
Dim sqlda As New SqlClient.SqlDataAdapter("Delete from tblpasien where No_Rkm_Mds=" & Me.No_Rkm_MdsTextBox.Text, Me.KlinikGigiDataSet)
sqlda.Fill(dbpasien, "tblpasien")
MsgBox("Data telah berhasil dihapus")
bersih()
pasif()
normal()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub bersih()
Me.No_Rkm_MdsTextBox.Clear()
Me.NamaTextBox.Clear()
Me.UmurTextBox.Clear()
Me.Tgl_LhrTextBox.Clear()
Me.AlamatTextBox.Clear()
Me.No_HpTextBox.Clear()
Me.No_Rkm_MdsTextBox.Focus()
End Sub
Private Sub pasif()
Me.No_Rkm_MdsTextBox.Enabled = False
Me.NamaTextBox.Enabled = False
Me.UmurTextBox.Enabled = False
Me.Tgl_LhrTextBox.Enabled = False
Me.AlamatTextBox.Enabled = False
Me.No_HpTextBox.Enabled = False
End Sub
Private Sub normal()
Me.bt_tambah.Enabled = True
Me.bt_edit.Enabled = True
Me.bt_simpan.Enabled = False
Me.bt_reset.Enabled = False
Me.bt_hapus.Enabled = False
Me.bt_keluar.Enabled = True
End Sub
Private Sub binding()
Me.No_Rkm_MdsTextBox.DataBindings.Clear()
Me.No_Rkm_MdsTextBox.DataBindings.Add("Text", dvpasien, "Id")
Me.NamaTextBox.DataBindings.Clear()
Me.NamaTextBox.DataBindings.Add("Text", dvpasien, "Nama")
Me.UmurTextBox.DataBindings.Clear()
Me.UmurTextBox.DataBindings.Add("Text", dvpasien, "Alamat")
Me.Tgl_LhrTextBox.DataBindings.Clear()
Me.Tgl_LhrTextBox.DataBindings.Add("Text", dvpasien, "Ttl")
Me.AlamatTextBox.DataBindings.Clear()
Me.AlamatTextBox.DataBindings.Add("value", dvpasien, "Jkl")
Me.No_HpTextBox.DataBindings.Clear()
Me.No_HpTextBox.DataBindings.Add("Text", dvpasien, "Pekerjaan")
End Sub
Private Sub No_Rkm_MdsTextBox_TextChanged(sender As Object, e As EventArgs) Handles No_Rkm_MdsTextBox.TextChanged
If Len(Me.No_Rkm_MdsTextBox.Text) < 10 Then
Exit Sub
End If
dvpasien.Sort = "Id"
Try
cari = dvpasien.Find(Me.No_Rkm_MdsTextBox.Text)
If cari = -1 Then
If tekan = 1 Then
Me.No_Rkm_MdsTextBox.Focus()
Else
MsgBox("Data tidak ada")
bersih()
End If
Else
If tekan = 1 Then
MsgBox("Data sudah ada")
bersih()
Else
binding()
tampilgrid()
Me.bt_edit.PerformClick()
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub tampilgrid()
Throw New NotImplementedException
End Sub
End Class
Please help this is my essay from my lecturer.
Have you declared your dataset with New keyword?
Means something as follows:
Dim dbpasien As New DataSet()
Or
Using dbpasien As DataSet = New DataSet()
MSDN explains this exception is due to bad overloaded method types
You have made a call to an overloaded method, but the compiler cannot find a method that can be called without a narrowing conversion. A narrowing conversion changes a value to a data type that might not be able to precisely hold some of the possible values.

Access level on VB.NET

I have created a system and im new to vb.net. It is working fine. The problem is, I need to restrict the main page from 1.) Users and 2.) Admin.
For example, After logging in, Admin will proceed to the main page
And if users logs in, they will be directed to a different page
I'm still new to vb.net (like 6 weeks ago) and i am using microsoft access as my database. A lot of code I find online is very complex and technical. I just need simple vb.net code
Any help will be appreciated, thank you!!
i have posted my code for my login form, so you guys can further understand my coding:
Public Class Form1
Dim loginerror As String
Public Function login()
Dim DBconn As New ADODB.Connection
Dim user As New ADODB.Recordset
Dim Username As String
Dim userDB As String
Dim passDB As String
Dim UserFound As Boolean
DBconn.Open("Provider = Microsoft.Jet.OLEDB.4.0;" & _
"Data Source = '" & Application.StartupPath & "\LoginDB.mdb'")
user.Open("UserTable", DBconn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
UserFound = False
login = False
Username = "Username = '" & txtuser.Text & "'" '
Do
user.Find(Username)
If user.BOF = False And user.EOF = False Then
userDB = user.Fields("Username").Value.ToString
passDB = user.Fields("Password").Value.ToString
If userDB <> txtuser.Text Then
user.MoveNext()
Else
UserFound = True
If passDB = txtpass.Text Then
user.Close()
DBconn.Close()
Return True
Else
loginerror = "Invalid Password"
user.Close()
DBconn.Close()
Return False
End If
End If
Else
loginerror = "Invalid Username"
user.Close()
DBconn.Close()
Return False
End If
Loop Until UserFound = True
user.Close()
DBconn.Close()
Return False
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If login() = True Then
Welcome.Show()
Me.Close()
Else
MessageBox.Show(loginerror, "Login Message")
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AcceptButton = Button1
Me.Show()
Application.DoEvents()
txtuser.Focus()
End Sub
Private Sub txtpass_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtpass.TextChanged
End Sub
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
End Sub
Private Sub txtuser_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtuser.TextChanged
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
End Sub
Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
End Sub
End Class
Just in case here is my coding for my main form:
Public Class Mainform
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Select MessageBox.Show("Are you sure you want to exit?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
Case Windows.Forms.DialogResult.Yes
Case Windows.Forms.DialogResult.No
e.Cancel = True
End Select
End Sub
Private Sub Mainform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.WorkTableAdapter.Fill(Me.LoginDBDataSet.Work)
Me.AssetTableAdapter.Fill(Me.LoginDBDataSet.Asset)
Me.HistoryTableAdapter.Fill(Me.LoginDBDataSet.History)
Me.InventoryTableAdapter.Fill(Me.LoginDBDataSet.Inventory)
Me.Equipment1TableAdapter.Fill(Me.LoginDBDataSet.Equipment1)
End Sub
Private Sub mainform_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.Escape Then Me.Close()
End Sub
Private Sub Equipment1BindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Equipment1BindingNavigatorSaveItem.Click
Me.Validate()
Me.Equipment1BindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.LoginDBDataSet)
End Sub
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
Mainform_Load(Me, New System.EventArgs)
End Sub
Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
Form1.Show()
Me.Dispose()
Me.Close()
End Sub
Private Sub TabPage1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage1.Click
End Sub
Private Sub IDLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TabPage5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage5.Click
End Sub
Private Sub Equipment_NameTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub HistoryDataGridView_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs)
End Sub
Private Sub InventoryDataGridView_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs)
End Sub
Private Sub TabControl1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
End Sub
Private Sub Machine_IDTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub _WO_CompletedLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub _WO_CompletedCheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub _WO_CompletedCheckBox_CheckedChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Machine_IDTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Machine_IDTextBox1.TextChanged
End Sub
Private Sub _WO_CompletedCheckBox_CheckedChanged_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _WO_CompletedCheckBox.CheckedChanged
End Sub
End Class
you need to determine if the user is administrator or not (usually your user table should have a role attached to the user e.g. administration, employee, etc.)
something like this when you try to log in
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If login() = True and UserRole='Administrator' Then
Welcome.Show()
Me.Close()
elseif login() = True then
WelcomeUser.Show()
Me.Close()
Else
MessageBox.Show(loginerror, "Login Message")
End If
End Sub

CheckBox Saved with IsolatedStorage (vb)

I have a problem loading the saved setting of a CheckBox (Checked True or False). On calling up the saved setting it always comes back as True from IsolatedStorage weather the CheckBox has been checked or not? Please see the code attached and I would appreciate it if someone could show me the error of my ways.
Kind regards
Will
Private Sub Button2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button2.Click
'Rem Save Settings'
If CheckBox1.IsChecked = True Then
IsolatedStorageSettings.ApplicationSettings("MyCheckBox") = CheckBox1.IsChecked = True
ElseIf CheckBox1.IsChecked = False Then
IsolatedStorageSettings.ApplicationSettings("MyCheckBox") = CheckBox1.IsChecked = False
End If
End Sub
Private Sub Button3_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button3.Click
' Rem Call Up Saved Settings'
MessageBox.Show("Choose Tank Procedure First")
CheckBox1.IsChecked = (IsolatedStorageSettings.ApplicationSettings("MyCheckBox"))
End Sub
This Answer was kindly given to me by Karmjit Singh from the Microsoft Silverlight Forunm
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
If IsolatedStorageSettings.ApplicationSettings.Contains("MyCheckSettings") Then
IsolatedStorageSettings.ApplicationSettings("MyCheckSettings") = CheckBox1.IsChecked
Else
IsolatedStorageSettings.ApplicationSettings.Add("MyCheckSettings", CheckBox1.IsChecked)
End If
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button2.Click
Dim x As Boolean?
IsolatedStorageSettings.ApplicationSettings.TryGetValue(Of Boolean?)("MyCheckSettings", x)
CheckBox2.IsChecked = x
End Sub

Resources