Dim mItem As Item mItem = New Item mConfig.Add(mItem) mItem = New Item With mItem .ID = 1 .User = "Master" .Password = "123456" .Tusted = False End With mConfig.Add(mItem) mConfig.SaveXmlFile(Application.StartupPath & "\Config.xml") End Sub '测试读配置文件 Private Sub TestLoadConfig() Dim mConfig As Config = New Config mConfig = mConfig.LoadXmlFile(Application.StartupPath & "\Config.xml") '读取默认值的用户名 MsgBox(mConfig.Items(mConfig.ID).User) '不妨修改一下配置 mConfig.ID = 1 mConfig.ConnectionInfo(0).Server = "Server" mConfig.ConnectionInfo(1).Database = "Master" '再存盘 mConfig.SaveXmlFile(Application.StartupPath & "\Config.xml") End Sub |