Solved

List Boxes

Posted on 2001-06-04
9
130 Views
Last Modified: 2010-05-18
can I format the Output of a list box with the tab control?
If so how is it done?

Thank you, John
0
Comment
Question by:johnm112496
9 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6154593
Hi, use Format function.
0
 

Author Comment

by:johnm112496
ID: 6154600
ryancys: Is that instead of the tab control?
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6154618
You mean tabstrip control?
0
 

Author Comment

by:johnm112496
ID: 6154632
no i mean as in print tab (9) "hi" is there any way to do this in a list box?
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6154732
Hi John,

Sorry, actually i not really understand what's the problem you facing now. Please explain detail.

As using Format function (Cuts from MSDN):


This example shows various uses of the Format function to format values using both named formats and user-defined formats. For the date separator (/), time separator (:), and AM/ PM literal, the actual formatted output displayed by your system depends on the locale settings on which the code is running. When times and dates are displayed in the development environment, the short time format and short date format of the code locale are used. When displayed by running code, the short time format and short date format of the system locale are used, which may differ from the code locale. For this example, English/U.S. is assumed.

MyTime and MyDate are displayed in the development environment using current system short time setting and short date setting.

Dim MyTime, MyDate, MyStr
MyTime = #17:04:23#
MyDate = #January 27, 1993#

' Returns current system time in the system-defined long time format.
MyStr = Format(Time, "Long Time")

' Returns current system date in the system-defined long date format.
MyStr = Format(Date, "Long Date")

MyStr = Format(MyTime, "h:m:s")   ' Returns "17:4:23".
MyStr = Format(MyTime, "hh:mm:ss AMPM")   ' Returns "05:04:23 PM".
MyStr = Format(MyDate, "dddd, mmm d yyyy")   ' Returns "Wednesday,
   ' Jan 27 1993".
' If format is not supplied, a string is returned.
MyStr = Format(23)   ' Returns "23".

' User-defined formats.
MyStr = Format(5459.4, "##,##0.00")   ' Returns "5,459.40".
MyStr = Format(334.9, "###0.00")   ' Returns "334.90".
MyStr = Format(5, "0.00%")   ' Returns "500.00%".
MyStr = Format("HELLO", "<")   ' Returns "hello".
MyStr = Format("This is it", ">")   ' Returns "THIS IS IT".


'Hope will help.

0
 

Author Comment

by:johnm112496
ID: 6154766
Tab[(n)]

The optional nargument is the column number moved to before displaying or printing the nextexpression in a list. If omitted, Tab moves the insertion point to the beginning of the nextprint zone. This allows Tab to be used instead of a comma inlocales where the comma is used as a decimal separator
now is there anyway to do the above in the listbox?
I have my our pur going int a listbox what I want formatted to a specific column, is there anyway to do the above in a list box!
John
0
 
LVL 4

Accepted Solution

by:
TigerZhao earned 150 total points
ID: 6154770
Option Explicit
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

' Sets tab stops of the list box.
' IN: [TabStops] - in Pixel.
' RETURNS: True if set, False if not.
Sub LBSetTabWidths(LB As ListBox, ParamArray TabStops() As Variant)
    Dim arrTabStops()   As Long
    Dim lUBound         As Long
    Dim I               As Long
   
    lUBound = UBound(TabStops)
    ReDim arrTabStops(lUBound) As Long
    For I = 0 To lUBound
        arrTabStops(I) = TabStops(I)
    Next
       
    ' Clear existing tab stops settings.
    SendMessage LB.hwnd, LB_SETTABSTOPS, ByVal 0&, 0&
    SendMessage LB.hwnd, LB_SETTABSTOPS, ByVal lUBound, arrTabStops(0)
End Sub

Private Sub Form_Load()
    LBSetTabWidths List1, 50, 30
    List1.AddItem "Name" & vbTab & "Sex" & vbTab & "Age"
    List1.AddItem "Lisa" & vbTab & "Female" & vbTab & "20"
    List1.AddItem "John" & vbTab & "Male" & vbTab & "24"
End Sub
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6154905
TigerZhao, please post your Answer as Comment. See the "Tips on Comments and Answers" below..
0
 
LVL 1

Expert Comment

by:frankylew
ID: 6254994
Nancy, Tiger can post his suggestion as Answer if he is confident with his code tat could solve the prob. No offend ya, nancy. :P
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now