# Force Slider to Specific Intervals Try using a slider control in your UI if you’re tired of combo boxes. Users find this control intuitive to understand and operate. For example, you might use the slider control to obtain values from a user in increments of \$1,000. First, add the slider control to a form. Set the slider’s Min and Max properties to the appropriate range for your app. Then, set the TickFrequency property equal to any interval of interest. Using the example, try setting the slider properties to: Min=1,000 and Max=10,000. Unfortunately, if a user drags the slider instead of clicking on it, values between the tick marks are returned. Here’s a cool way to easily control this behavior. Place this code in the slider’s Change event, substituting your control’s name:

`` Private Sub slBWidth_Change()	slBWidth = CInt(slBWidth.Value / slBWidth. _		TickFrequency) * slBWidth.TickFrequencyEnd Sub``

Now try it out to see how the control behaves. The result is the same as scaling the slider from 1 to 10, then multiplying by a scale factor for the value. The difference is that it now free-slides instead of jerking between ticks.

Share the Post:

Recent Articles:
{"ft_lang_label":"__label__en","ft_lang_prob":0.83325684,"math_prob":0.75426275,"size":1103,"snap":"2022-40-2023-06","text_gpt3_token_len":252,"char_repetition_ratio":0.14467698,"word_repetition_ratio":0.0,"special_character_ratio":0.22121488,"punctuation_ratio":0.12612613,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96453744,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-01-28T06:42:33Z\",\"WARC-Record-ID\":\"<urn:uuid:f594639a-a668-4d09-954e-89d7999e173a>\",\"Content-Length\":\"111110\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e0bb6d25-716d-4c3c-bf48-9294b3469128>\",\"WARC-Concurrent-To\":\"<urn:uuid:f6428c24-8a97-470d-973e-e8867b308ea2>\",\"WARC-IP-Address\":\"172.67.213.166\",\"WARC-Target-URI\":\"https://www.devx.com/tip-bank/13929/\",\"WARC-Payload-Digest\":\"sha1:TEKU5PVORMYOFG3TRAVNDTN73GOCUSVC\",\"WARC-Block-Digest\":\"sha1:64PYUKOSL2XGWVYGOPYLXCP5SGYJB7RV\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-06/CC-MAIN-2023-06_segments_1674764499524.28_warc_CC-MAIN-20230128054815-20230128084815-00240.warc.gz\"}"}