Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

List Boxes

Posted on 2001-06-04
9
Medium Priority
?
144 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 53

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 53

Expert Comment

by:Ryan Chong
ID: 6154618
You mean tabstrip control?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 53

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 53

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

Industry Leaders: 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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

721 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