how to fill combo box to look like thisCode:For i = 1 To 100
cboRange.AddItem i
Next
cboRange.ListIndex = 0
from 0.00 to 100.00 ?
Printable View
how to fill combo box to look like thisCode:For i = 1 To 100
cboRange.AddItem i
Next
cboRange.ListIndex = 0
from 0.00 to 100.00 ?
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
simply: Combo1.AddItem CStr(lngCounter) & ".00"
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
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! :)
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