LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default the most frustrating control


what i have is a userform with a combo box, cmbSelectIngredient, and two
text boxes, txtIngredientName and txtAmount. in the DropButtonClick
event of the combo box i have this code:

Code:
--------------------

Private asIngredientNames(24) As String
Private adIngredientAmounts(24) As Single

Private Sub cmbSelectIngredient_DropButtonClick()
If txtIngredientName.Text = "" Then
Exit Sub
Else
asIngredientNames(cmbSelectIngredient.ListIndex) = CStr(txtIngredientName.Text)
End If
If txtAmount.Text = "" Then
adIngredientAmounts(cmbSelectIngredient.ListIndex) = 0
Else
adIngredientAmounts(cmbSelectIngredient.ListIndex) = CSng(txtAmount.Text)
End If

cmbSelectIngredient.AddItem "Ingredient " & cmbSelectIngredient.ListIndex + 1
End Sub
--------------------


and in the Change event i have this code:

Code:
--------------------
Private Sub cmbSelectIngredient_Change()
If asIngredientNames(cmbSelectIngredient.ListIndex) < "" Then
If adIngredientAmounts(cmbSelectIngredient.ListIndex) = 0 Then
GoTo Skip
Else
txtAmount.Text = adIngredientAmounts(cmbSelectIngredient.ListIndex)
End If
txtIngredientName.Text = asIngredientNames(cmbSelectIngredient.ListIndex)
End If
Skip:
txtIngredientName.Text = ""
txtAmount.Text = ""
End Sub
--------------------

and this as initialization:

Code:
--------------------
Private Sub UserForm_Initialize()
cmbSelectIngredient.AddItem "Ingredient " & 1
cmbSelectIngredient.ListIndex = 0
End Sub
--------------------


basically, what i try to achieve with this code is storing a string and
a single into thier corresponding arrays, then when a previously stored
ingredient is selected, i would like to fill the textboxes with the
information previously stored in the array. but i'm getting all sorts
of problems. mainly because i can't figure out how to recall the
values into the textboxes. my code seems like it would do it, but
since the ListIndex isn't changed until after the Change event it
called, i think it may be impossible to do because i can't predict
which line the user will select. maybe there's some way of finding out
which line is selected before the Change event is called?


--
medicenpringles


------------------------------------------------------------------------
medicenpringles's Profile: http://www.excelforum.com/member.php...o&userid=16458
View this thread: http://www.excelforum.com/showthread...hreadid=492920

 
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
the most frustrating control Alok Excel Programming 0 December 13th 05 12:29 AM
Very Frustrating - Please Help! picklevote Excel Worksheet Functions 1 September 14th 05 01:32 AM
Frustrating Problem Rebecca New Users to Excel 3 April 4th 05 02:35 PM
Simple but frustrating Gordon[_2_] Excel Programming 4 December 18th 04 09:06 PM
Bizarre and frustrating bug NJD Excel Programming 5 January 28th 04 09:50 PM


All times are GMT +1. The time now is 03:16 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"