Solved

List Boxes

Posted on 2001-06-04
9
132 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 50

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 50

Expert Comment

by:Ryan Chong
ID: 6154618
You mean tabstrip control?
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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 50

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 50

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA saving file message display 5 65
Determine Range to Select 5 48
Convert VB6 MSXML2.ServerXMLHTTP process to C# 2 47
VBA: Select SQL query based on a config Sheet v2 11 44
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 …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

772 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