While I agree that it is very bad practice to use a Try/Catch block (particularly with an empty Catch) in this case or any case as a way of controlling non-exceptional program flow, please note that it is possible for ModuleSettings or TabModuleSettings to return null if the setting has not been previously defined - as is often the case for a newly added module whose Settings page has not been opened previously. For this latter reason, I always initialize a module's settings to default values when the module is first added to a page. Thanks to the introduction of generics in .NET 2.0, it is also possible to define a function like the following in your module's code (or better yet in a base class deriving from PortalModuleBase that can contain other methods common to all modules you develop):
Private Function GetSetting(Of T)(ByVal SettingName As String, ByVal DefaultValue As T) As T
Dim obj As Object = Settings(SettingName)
If obj Is Nothing Then
Return DefaultValue
Else
Return Convert.ChangeType(obj, GetType(T)) 'or CType(obj, T) - not sure which is better performance
End If
End Function
Any thoughts on the performance implications of using such a function or of always initializing all of a module's settings to default values when the module is first added to a page?