Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

List Boxes

Posted on 2001-06-04
9
Medium Priority
?
148 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 54

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 54

Expert Comment

by:Ryan Chong
ID: 6154618
You mean tabstrip control?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
LVL 54

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 600 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 54

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

916 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