|
-
Feb 28th, 2007, 03:09 AM
#1
Thread Starter
Addicted Member
[2005]Accept Variable in Listbox index
Hello All,
I have an issue that has been plaguing me for some time now and I have gone at it with all of the limited knowledge that I possess and I can't figure out how to pull the value that is stored in a certain index of a listbox.
Let me walk you through what I have so far.
I have a simple form with:
3 listboxes: LisWorkShop, lisLocation, & LisCost
4 buttons: Only two worth noting at this point - btnWorkShop & btnCalculate
1 label: lblTotalCost
The idea behind this program is that you select a training that you would like to take from the LisWorkShop list and click btnWorkShop to add the cost to LisCost. This is the code I have for btnWorkShop:
Code:
If LisWorkshop.SelectedIndex = -1 Then
MessageBox.Show("Please select a training session")
ElseIf LisWorkshop.SelectedIndex = 0 Then
LisCost.Items.Add(FormatCurrency(595))
ElseIf LisWorkshop.SelectedIndex = 1 Then
LisCost.Items.Add(FormatCurrency(695))
ElseIf LisWorkshop.SelectedIndex = 2 Then
LisCost.Items.Add(FormatCurrency(995))
ElseIf LisWorkshop.SelectedIndex = 3 Then
LisCost.Items.Add(FormatCurrency(1295))
ElseIf LisWorkshop.SelectedIndex = 4 Then
LisCost.Items.Add(FormatCurrency(395))
End If
I know I have the FormatCurrency listed for each statement, I will correct that once I have the code locked down.
In the second List box, LisLocation, I have a list of cities in which the training is offered. On click in LisLocation the amount of lodging is moved into LisCost. The code I have to do this is the following:
Code:
If LisLocation.SelectedIndex = 0 Then
LisCost.Items.Add(FormatCurrency(95))
ElseIf LisLocation.SelectedIndex = 1 Then
LisCost.Items.Add(FormatCurrency(125))
ElseIf LisLocation.SelectedIndex = 2 Then
LisCost.Items.Add(FormatCurrency(110))
ElseIf LisLocation.SelectedIndex = 3 Then
LisCost.Items.Add(FormatCurrency(100))
ElseIf LisLocation.SelectedIndex = 4 Then
LisCost.Items.Add(FormatCurrency(92))
ElseIf LisLocation.SelectedIndex = 5 Then
LisCost.Items.Add(FormatCurrency(90))
End If
Once these two subs take place I have at least two values in LisCost. The PROBLEM I am having is finding a way to access the amount of those indexes, not the index number themselves. I don't have the knowledge needed to pull the information.
How would I go about pulling the value of the indexes in order to add the costs together. All attempts I have used to find the values of the indexes result in me getting the index itself.
I know this is simple but for a first year student this is just mind boggling at this point. I haven't had any training above If...Then, Select Cases, and Loops.. As you can tell by the extent of my post this is killing me. I have a feeling something is escaping me about the listbox control or method... the problem being that its escaped me for two days now!
I will be monitoring for the next 8 hours so let your suggestions fly!
Abrium
Asking the beginners questions so you don't have to!
If by chance hell actually froze over and I some how helped you... Please rate.
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
|