Prevent Errors When Using GetSetting

Using Visual Basic’s GetSetting function might cause an error, particularly in certain situations when using itunder 16-bit operating systems with INI files. If there’s no specific entry in the INI file, you might get anerror message such as “Invalid procedure call.” You can use this routine, which wraps an error handleraround the built-in function:

 Public Function GetRegSetting(AppName _        As Variant, Section As Variant, _        Key As Variant, Optional Default _        As Variant) As Variant' the default value is not assumed to be ' an Object type otherwise you should ' use Set statementDim tmpValue As Variant' set default value' if no value was passed, this gives an ' empty variantIf Not IsMissing(Default) Then _        tmpValue = Default' this is for trapping possible errorsOn Error Resume Next' let's use VB's functiontmpValue = GetSetting(AppName, _        Section, Key, tmpValue)' after possible errors the call ' continues here with the preset default ' valueGetRegSetting = tmpValueEnd Function
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS