Imports System.Configuration
Imports System.IO
Imports System.Xml.Serialization
Imports SNAP.GlobalVars
Public Module iXML
Sub setXML(ByVal SetKey As String, ByVal SetVal As String)
Try
Dim xmlFile As New StreamWriter(xmlPath)
Dim xmlWriter As New XmlSerializer(GetType(UserPrefs))
Dim xmlSetKey As New UserPrefs
Select Case SetKey
Case "AutoSelect" : xmlSetKey.AutoSelect = SetVal
Case "Countdown" : xmlSetKey.Countdown = SetVal
Case "LagPrompt" : xmlSetKey.LagPrompt = SetVal
Case "MyTeam" : xmlSetKey.MyTeam = SetVal
Case "NoMatches" : xmlSetKey.NoMatches = SetVal
Case "SkipIntro" : xmlSetKey.SkipIntro = SetVal
Case "SwapPlayers" : xmlSetKey.SwapPlayers = SetVal
Case "GeneralHelp" : xmlSetKey.GeneralHelp = SetVal
End Select
xmlWriter.Serialize(xmlFile, xmlSetKey)
xmlFile.Close()
Catch
End Try
End Sub
Public Function getXML(ByVal GetKey As String)
If Not (File.Exists(xmlPath)) Then Return Nothing
Dim xmlRtnVal As String = ""
Try
Dim xmlFile As New StreamReader(xmlPath)
Dim xmlReader As New XmlSerializer(GetType(UserPrefs))
With CType(xmlReader.Deserialize(xmlFile), UserPrefs)
Select Case GetKey
Case "AutoSelect" : xmlRtnVal = .AutoSelect
Case "Countdown" : xmlRtnVal = .Countdown
Case "LagPrompt" : xmlRtnVal = .LagPrompt
Case "MyTeam" : xmlRtnVal = .MyTeam
Case "NoMatches" : xmlRtnVal = .NoMatches
Case "SkipIntro" : xmlRtnVal = .SkipIntro
Case "SwapPlayers" : xmlRtnVal = .SwapPlayers
Case "GeneralHelp" : xmlRtnVal = .GeneralHelp
End Select
End With
Catch
End Try
Return xmlRtnVal
End Function
End Module
Public Class UserPrefs
Public AutoSelect As String
Public Countdown As String
Public LagPrompt As String
Public MyTeam As String
Public NoMatches As String
Public SkipIntro As String
Public SwapPlayers As String
Public GeneralHelp As String
End Class
And the subroutine that calls it: Private Sub chkQuikTip1_CheckedChanged(sender As Object, e As EventArgs) Handles _
chkQuikTip1.CheckedChanged, chkQuikTip2.CheckedChanged, chkQuikTip3.CheckedChanged, chkQuikTip4.CheckedChanged,
chkQuikTip5.CheckedChanged, chkQuikTip6.CheckedChanged, chkQuikTip7.CheckedChanged, chkQuikTip8.CheckedChanged
Dim WhatWasChecked As String = sender.Tag
If WhatWasChecked IsNot Nothing Then
Call setXML(WhatWasChecked, sender.Checked.ToString)
End If
End Sub
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.