|
-
Jan 9th, 2012, 12:12 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Combo box fill ?
Code:
For i = 1 To 100
cboRange.AddItem i
Next
cboRange.ListIndex = 0
how to fill combo box to look like this
from 0.00 to 100.00 ?
-
Jan 9th, 2012, 12:19 PM
#2
Addicted Member
Re: Combo box fill ?
I'm sure there are otherways to do this but just off the cuff....
vb Code:
Private Sub Form_Load() Dim lngCounter As Long Combo1.Text = Format(CStr(lngCounter), "##0.00") For lngCounter = 0 To 100 Combo1.AddItem Format(CStr(lngCounter), "##0.00") Next lngCounter End Sub
Last edited by Darren M.; Jan 9th, 2012 at 12:23 PM.
-
Jan 9th, 2012, 12:38 PM
#3
Thread Starter
Hyperactive Member
Re: Combo box fill ?
 Originally Posted by Darren M.
I'm sure there are otherways to do this but just off the cuff....
vb Code:
Private Sub Form_Load()
Dim lngCounter As Long
Combo1.Text = Format(CStr(lngCounter), "##0.00")
For lngCounter = 0 To 100
Combo1.AddItem Format(CStr(lngCounter), "##0.00")
Next lngCounter
End Sub
thx, but what about regional settings, for some region it will be "." and for some ","
how to avoid that so that will be only "." dot ?
-
Jan 9th, 2012, 12:45 PM
#4
Re: Combo box fill ?
simply: Combo1.AddItem CStr(lngCounter) & ".00"
-
Jan 9th, 2012, 01:28 PM
#5
Frenzied Member
Re: Combo box fill ?
can you use currency as your type
it would i think default to the regional settings
i dont have access to a vb machine only vba at the moment
here to help
just checked vb6 has type currency so thats you sorted or is it?
if so please close the thread usingthe tool on the top bar and please
rate the posts that have helped you
Last edited by incidentals; Jan 9th, 2012 at 01:34 PM.
-
Jan 9th, 2012, 01:42 PM
#6
Thread Starter
Hyperactive Member
Re: Combo box fill ?
 Originally Posted by LaVolpe
simply: Combo1.AddItem CStr(lngCounter) & ".00"
Thx to both of you...
-
Jan 9th, 2012, 02:08 PM
#7
Addicted Member
Re: Combo box fill ?
 Originally Posted by VB Client/Server
thx, but what about regional settings, for some region it will be "." and for some ","
how to avoid that so that will be only "." dot ?
Ya know, that's a really good question. Unfortunately, I have little to no experience with the "," requirement. (I'm spoiled I suppose.) Let me play around w/ that a bit and I'll see if I can work up something a bit more dynamic. It's cold and rainy here today, I need a challenge. Thanks!
-
Jan 9th, 2012, 02:46 PM
#8
Addicted Member
Re: [RESOLVED] Combo box fill ?
Well, I wish I could claim this code as my own but I stole it from a Google search...
http://visualbasic.about.com/b/2005/...k-for-vb-6.htm
The suggestion there implemented in the code above, with LaVolpe's suggested execution. 
(So simple.....)
This works in the US. Please test w/ your region and advise.
[edit]
Just tested on my Windows 7 w/ different regional settings, works great.
[/edit]
vb Code:
Private Sub Form_Load() Dim strLocalDecimal As String Dim strLocalComma As String Dim lngCounter As Long Dim strErrMsg As String On Error GoTo ERRORHANDLER strLocalDecimal = Mid$(CStr(11 / 10), 2, 1) strLocalComma = Chr$(90 - Asc(strLocalDecimal)) Combo1.Text = CStr(lngCounter) & strLocalDecimal & "00" For lngCounter = 0 To 100 Combo1.AddItem CStr(lngCounter) & strLocalDecimal & "00" Next lngCounter GoTo OVERERROR ERRORHANDLER: If LenB(strErrMsg) = 0 Then strErrMsg = Err.Number & ": " & Err.Description End If MsgBox strErrMsg, vbCritical, "Error" OVERERROR: End Sub
Last edited by Darren M.; Jan 9th, 2012 at 03:04 PM.
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
|