473,401 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Arrange Text in a ListBox?

Hello all,

I'll get to the point. Does anyone know how i go about arranging text in a
list box?

I am loading a name and number into a listbox from an array, using code
snippet below:

For s = 1 To amtOfRecords
lstSorted.AddItem (numArray(s) & " " &
nameArray(s))
Next s

I have used the series of spaces in between to seperate the name & number.
But the number field all seem out-of-line when they're printed into the
ListBox.

Can anyone help me fix this for them to be aligned?
Jul 17 '05 #1
1 2767
On Thu, 16 Oct 2003 09:19:33 +0100, "Brian Basquille"
<tb********@eircom.netSPAM> wrote:
Hello all,

I'll get to the point. Does anyone know how i go about arranging text in a
list box?

I am loading a name and number into a listbox from an array, using code
snippet below:

For s = 1 To amtOfRecords
lstSorted.AddItem (numArray(s) & " " &
nameArray(s))
Next s

I have used the series of spaces in between to seperate the name & number.
But the number field all seem out-of-line when they're printed into the
ListBox.

Can anyone help me fix this for them to be aligned?


Option Explicit

' Add one Listbox
' Add one command button

Private Declare Function SendMessage _
Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Const LB_SETTABSTOPS = &H192
' ################################################## ###
'
' TabWidth(0) = Number of Tabs
' TabWidth(1 to n) = Width of Each Field in Bytes
'
Sub SetTabWidths(TabWidth() As Long)
Dim Max&, L9%
If TabWidth(0) < 1 Or TabWidth(0) > UBound(TabWidth) Then
MsgBox ("EPL - Bad TabWidth(0) in SetTabWidths")
End If
Max = TabWidth(0)
ReDim Q&(Max + 1)
For L9 = 1 To Max
Q(L9) = TabWidth(L9) * 4 ' 4 Dialog Units Per Char
Q(L9) = Q(L9 - 1) + Q(L9)
Next
Call SendMessage(List1.hWnd, LB_SETTABSTOPS, Max, Q&(1))
End Sub

Private Sub Command1_Click()
Dim L9, Q&(2)
For L9 = 1 To 20
List1.AddItem Str$(L9) + vbTab _
+ Str$(L9) + "a" + vbTab _
+ "Col3"
Next

Q(0) = 2 ' 1st Column is zero offset
Q(1) = 10
Q(2) = 10
Call Me.SetTabWidths(Q())
End Sub


Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have...
2
by: David Ichilov | last post by:
I've class derived from "Object" class, with ToString() method overriden itc. , now i add object of this class to Windows.Forms.ListBox.Items collection, and it works fine, displaying what...
4
by: CrimeMaster | last post by:
HI I have an Exe file when it runs ,there are just two controls on the window.One is a ListBox and another is a Multi line Rich Edit control.When i click on an item in the list some text is...
6
by: BerkshireGuy | last post by:
On an unbound form, I have a combobox called 'cboproducttype' and a text box called 'txtamountappliedfor'. I have an Add button that I would like the user to be able to hit once a product and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.