Imports System.Configuration
Imports System

Public Class AppConfig

    Public Shared Function GetConfiguration() As ConfigValues
        Dim appfile As String = My.Application.Info.DirectoryPath & "\" & My.Application.Info.Title & ".exe"
        Dim appconfig As Configuration = ConfigurationManager.OpenExeConfiguration(appfile)
        Dim appsettings As AppSettingsSection = appconfig.AppSettings
        Dim settings As KeyValueConfigurationCollection = appsettings.Settings

        Dim username As String = settings.Item("username").Value
        Dim password As String = settings.Item("password").Value
        Dim query As String = settings.Item("query").Value
        Dim connstring As String = settings.Item("connstring").Value
        Dim database As String = settings.Item("database").Value

        Return New ConfigValues(username, password, query, connstring, database)
    End Function

End Class

Public Class ConfigValues
    Public username As String
    Public password As String
    Public query As String
    Public connstring As String
    Public database As String

    Public Sub New(_username, _password, _query, _connstring, _database)
        username = _username
        password = _password
        query = _query
        connstring = _connstring
        database = _database
    End Sub
End Class