Noticing that vbTab doesn't work in comboboxes, i produced this code. It is commented and needs only a little tweaking for your program.
[tt]
Private Sub Form_Load()
'Declare Arrays for each column equal to the
'amount of rows you want.
Dim Col1Data(20) As String
Dim Col2Data(20) As String
'Declare Looping and Adding Variables
Dim AddLoop As Integer
Dim CurrentRow As String
Dim RowAmount As Integer
'Set Space Constant for Start of Column 2
Const C2Start = 40
'Set Column Data
Col1Data(1) = "Row 1 Col 1"
Col1Data(2) = "Row2 Col1"
Col2Data(1) = "Row 1 Col 2"
Col2Data(2) = "Row2 Col2"
'Check How Much of the array contains data
For AddLoop = 1 To UBound(Col1Data)
If Col1Data(AddLoop) <> "" And Col2Data(AddLoop) <> "" Then
RowAmount = AddLoop
End If
Next
'Start Loop using Total amount of used array data
For AddLoop = 1 To RowAmount
'Insert Correct Number of Spaces Into String
'Using Space Constant - No. of characters in Col 1
CurrentRow = Col1Data(AddLoop) & _
Space(C2Start - Len(Col1Data(AddLoop))) & Col2Data(AddLoop)
'Add Row to Combobox
Combo1.AddItem CurrentRow, AddLoop - 1
Next AddLoop
End Sub
[/tt]
Hope this helps.
[tt]"Very funny, Scotty... Now Beam down my clothes."[/tt]
Or Modify Part of the code as below to insert a line seperator before the Second Column.
[tt]
'Insert Correct Number of Spaces Into String
'Using Space Constant - No. of characters in Col 1
CurrentRow = Col1Data(AddLoop) & _ Space(C2Start - 3 - Len(Col1Data(AddLoop))) & " | " & Col2Data(AddLoop)
[/tt]
Hope this helps.
[tt]"Very funny, Scotty... Now Beam down my clothes."[/tt]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.