-
Dec 17th, 2014, 10:57 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Need help Populate (Height or Tall) in combo box
How do I sort this out?
Example :
4'8"
4'9"
4'10"
4'11"
4'12"
5'1"
5'2"
5'3"
and so on....
Code:
Dim iCtr As Integer
Dim iLoop As Integer
For iCtr = 0 To 12
For iLoop = 4 To 6
List1.AddItem iLoop & "'" & Format(iCtr, "#0") & """"
Next iLoop
Next
Any Help?
-
Dec 17th, 2014, 11:06 PM
#2
Thread Starter
Hyperactive Member
Re: Need help Populate (Height or Tall) in combo box
-
Dec 17th, 2014, 11:15 PM
#3
Re: Need help Populate (Height or Tall) in combo box
You need to reverse your loops, make iLoop the outter loop and iCtr the inner loop also iCtr should be 0 to 11 so you don't end up with something like 4'12"
So when iLoop=4
iCtr= 0 to 11 and you get
4' 0"
4'1"
...
4'11"
Then iLoop becomes 5 and you get
5'0"
...
-
Dec 17th, 2014, 11:20 PM
#4
Thread Starter
Hyperactive Member
Re: Need help Populate (Height or Tall) in combo box
Originally Posted by DataMiser
You need to reverse your loops, make iLoop the outter loop and iCtr the inner loop also iCtr should be 0 to 11 so you don't end up with something like 4'12"
So when iLoop=4
iCtr= 0 to 11 and you get
4' 0"
4'1"
...
4'11"
Then iLoop becomes 5 and you get
5'0"
...
Code:
Public Sub heightLister(cbo As ComboBox)
Dim iWeight As Integer
cbo.Clear
Dim iCtr As Integer
Dim iLoop As Integer
For iLoop = 4 To 6
If iLoop = 4 Then
For iCtr = 0 To 12
cbo.AddItem iLoop & "'" & Format(iCtr, "#0") & """"
Next
ElseIf iLoop = 5 Then
For iCtr = 0 To 12
cbo.AddItem iLoop & "'" & Format(iCtr, "#0") & """"
Next
ElseIf iLoop = 6 Then
For iCtr = 0 To 12
cbo.AddItem iLoop & "'" & Format(iCtr, "#0") & """"
Next
End If
Next
End Sub
These code solve my problem.
-
Dec 18th, 2014, 12:08 AM
#5
Re: [RESOLVED] Need help Populate (Height or Tall) in combo box
You don't need any of those ifs in there. Why did you add those, all you are doing is repeating the code three times.
All you need is
Code:
For iLoop = 4 To 6
For iCtr = 0 To 12
cbo.AddItem iLoop & "'" & Format(iCtr, "#0") & """"
Next
Next
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
|