Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Mada Akhtar   on Nov 17 In MS Office Category.

  
Question Answered By: Hadil Khan   on Nov 17

: I had made  a user  form with three combo  box CboDay, CboMonth,
: CboYear in the initialize  user form  i had put  this cord but i
: want that it is working fine but i want to reduce the coding  and
wanted  that the value between 1 to 30 come in day . between 1 to
: 12 in month combobox  etc

Create a sub routine which adds integers to an object. Then
call that sub for each object you are initializing.


Private Sub UserForm_Initialize()

' Initialize Combo Boxes
AddIntegerItems CboDay, 1, 31
AddIntegerItems CboMonth, 1, 12
AddIntegerItems CboYear, 2006, 2011

End Sub


' Assumes an object which supports AddItem method
Private Sub AddIntegerItems(object, iRangeLow, iRangeHigh)

Dim iInteger
For iInteger = iRangeLow To iRangeHigh
object.AddItem iInteger
Next iInteger

End Sub

Share: 

 

This Question has 8 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on adding values in combobox Or get search suggestion and latest updates.


Tagged: