LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Listboxes on userform

Hi. Guys

What I would like to do:
Get the user to select a product from a list[listbox1-"VrdLys" ; Userform
UcalCost]
Once his made the selection - promp to supply the quantity in a textbox
[TxtQuantity]
Calculate the cost - which is equal to the amount entered in txtQuantity
* the corresponding price of the product selected in Listbox1
Prompt the user to confirm his selection.

What I've achieved:
The list slection with the corresponding price of each product.
The calulation displayed in TboxAntw works 100%

My problem!
The prompt to supply the quantity does not work the way I want it. Only
after I've entered a number in TxtQuantity does the Inputbox appear to get
the quantity from the user - the result is corectly displayed in TxtQuantity.
I have a command button (CmnCost) when clicked it does the calculation
which is corectly displayed in TboxAntw. I would like this calculation to
be "automated" - if the user supply the quantity - the calculation should
automatically be displayed in TboxAntw without using the command button.
Finally Im not sure how to get the user to confirm his selection on the
userform.

Tks in advance

This is my code:
Public Sub CalCost()
Dim N, TxtQuantity

'Get the product, quantity & calculate the cost
UCalCost.ListBox1.Clear

'select the item
UCalCost.ListBox1.RowSource = "VrdLys"
UCalCost.ListBox1.ListIndex = 0
UCalCost.TxtQuantity = ""
UCalCost.TboxAntw.Value = 0
UCalCost.Show
'get the number of the item selected in the box
N = UCalCost.ListBox1.ListIndex
With UCalCost.ListBox1
'Display selection & calc - sheet AanInlig
Worksheets("AanInlig").Range("tydvrd").Value = UCalCost.ListBox1.Value
Worksheets("AanInlig").Range("tydaan").Value = UCalCost.TxtQuantity.Value
Worksheets("AanInlig").Range("tydkos").Value = UCalCost.TboxAntw.Value

End With
Unload UCalCost
End Sub

This is the Userform code:
Private Sub CmnCost_Click()
If Me.TxtQuantity.Value < "" Then
prod = Me.ListBox1.Value
Pprice = Application.WorksheetFunction.Index(Range("VrdVerP ry") _
, Application.WorksheetFunction.Match(prod, Range("VrdLys"), 0))
TboxAntw = Pprice * TxtQuantity
End If
End Sub

Private Sub ListBox1_Click()

End Sub

Private Sub OkButton_Click()
ULysKoste.Hide
bContinue = True
End Sub

Private Sub TxtQuantity_Change()
TxtQuantity = Application.InputBox(prompt:="Quantity ?")
End Sub

--
HJN
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exiting listboxes in a userform nir020 Excel Programming 1 March 17th 09 12:50 PM
Userform with Multiple ListBoxes not working ExcelMonkey[_190_] Excel Programming 6 March 3rd 05 11:29 PM
Userform with 2 Listboxes Mike R. Excel Programming 2 February 12th 05 07:21 AM
Userform w/ Multiple listboxes that link miker1999[_13_] Excel Programming 1 April 27th 04 03:22 AM
Userform and reading multiple listboxes Bijl167[_6_] Excel Programming 3 December 8th 03 01:40 PM


All times are GMT +1. The time now is 02:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"