-
November 22nd, 2014, 04:01 PM
#1
New to VB, I need a better way to add Combo Boxes.
I am new to Visual Basic, and at the moment I am making a program that will calculate the amount of miles I drive from store to store (picking up items from store to store as a job). I have 6 Combo Boxes, each with the same locations that can be chosen. Also, I have a data table that shows the miles from each location. (Example : If I was in Houston, it would take X amount of miles to get to San Antonio, Y amount of Miles to get to Austin, etc. And If I was in Austin, it would take X amount of miles to get to Houston, and Y amount of Miles to get to San Antonio, etc.) I only know the "If Then" statements to complete this, but to put this for every combo box, it is a lot of typing, and I am sure there is a faster way.
Is anyone able to help me on this? I hope I explained it clear enough.
Many Thanks.
-
November 22nd, 2014, 04:14 PM
#2
Re: New to VB, I need a better way to add Combo Boxes.
Use an ARRAY() of Comboboxes, and dynamically add each one. Could use the same code, then iterate and add the totals
-
November 23rd, 2014, 12:28 AM
#3
Re: New to VB, I need a better way to add Combo Boxes.
Use a function that looks for the data in your data table and call it from the combobox click event, you can also add the other combo boxes to the handles clause so that all of them are handled by the same event if need be so you only need to write the code once.
Always use [code][/code] tags when posting code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|