Create an up-down box for your VB6 programs
Takeaway: The up-down box gives users the option of typing the number in directly or of clicking up or down buttons to increase or decrease the value. See how you can create an up-down box in your VB6 programs by combining two of VB's standard controls.
A number of commercial programs have an up-down box. This control is used when the user needs to enter a numerical value. The up-down box gives users the option of typing the number in directly or of clicking up or down buttons to increase or decrease the value. You can create this functionality in your VB6 programs by combining two of VB's standard controls.
Start by placing a TextBox control on your form. Then, place a Vertical Scroll Bar right next to the TextBox. Change the scroll bar control's height to match that of the TextBox. You want only the up and down buttons of the scroll bar to be visible—the central part and thumb will be hidden. Then, set scroll bar properties as follows:
Now put the following code in the form's Load event procedure to initialize the text box:
Text1.Text = VScroll1.Value
Finally, put the same code in the scroll bar control's Change event procedure to change the text box when the user clicks the scroll bar's up or down button:
Text1.Text = VScroll1.Value
Now you have a custom control that gives your users a choice for entering numeric values.
Advance your scripting skills to the next level with TechRepublic's free Visual Basic newsletter, delivered each Friday. Automatically sign up today!
Print/View all Posts Comments on this article
SponsoredWhite Papers, Webcasts, and Downloads
- Eleven Myths about 802.11 Wi-Fi Networks Global Knowledge
- 2007 IT Salary and Skills Survey: What Impacts Salaries? Global Knowledge
- ITIL Version 3.0 -- What It Means to You Global Knowledge
- The OSI Model: Understanding the Seven Layers of Computer Networks Global Knowledge
- Using the Six Laws of Persuasion in Negotiations Global Knowledge
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET
