Solved

List Boxes

Posted on 2001-06-04
9
137 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 52

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 52

Expert Comment

by:Ryan Chong
ID: 6154618
You mean tabstrip control?
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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 52

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 52

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
to transfer string from C lanaguage to VBA 4 85
Help me. 3 79
Export PDF Form fields to Access  or Excel  in Tab order 16 129
transition to visual .net from vb6 5 81
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 …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

751 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