p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

access thread: Tab Setting


Message #1 by "Stephen Birnie" <beelzebubs_offspring@h...> on Wed, 19 Jun 2002 12:18:38
Is there any way of setting the tab length in a text box? I have a text 
box that displays info from a second text box and a list box together. I 
want to be able to line up all the data. I am adding a tab between the two 
texts but because some of the words in the List are longer than others 
they are not being tabbed to the same position for the second word.

Example:
Private Sub btnAddText_Click()

   TextBox2 = TextBox2 & ListText & vbTab & TextBox1 & vbCrLf
 
End Sub

I hope I've made sense, any help would be great.

Stephen

Message #2 by "Kenny Alligood" <kennyalligood@h...> on Wed, 19 Jun 2002 10:32:36 -0400
------=_NextPart_001_0002_01C2177C.A10C0BE0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Try this - it may be what you are looking for...

Private Sub btnAddText_Click()

   TextBox2 =3D TextBox2 & ListText & "     " & TextBox1 & vbCrLf

End Sub

Just add the amount of spaces that you want between the quotes...

Kenny

----- Original Message -----
From: Stephen Birnie
Sent: Wednesday, June 19, 2002 7:11 AM
To: Access
Subject: [access] Tab Setting

Is there any way of setting the tab length in a text box? I have a text
box that displays info from a second text box and a list box together. I
want to be able to line up all the data. I am adding a tab between the tw
o
texts but because some of the words in the List are longer than others
they are not being tabbed to the same position for the second word.

Example:
Private Sub btnAddText_Click()

   TextBox2 =3D TextBox2 & ListText & vbTab & TextBox1 & vbCrLf

End Sub

I hope I've made sense, any help would be great.

Stephen

to unsubscribe send a blank email to G
et more from the Web.  FREE MSN Explorer download : http://explorer.msn.c
om

Message #3 by "Stephen Birnie" <beelzebubs_offspring@h...> on Wed, 19 Jun 2002 16:27:25
Sorry Kenny that won't work either.
What I'm trying to do is this:

I have a list of specification headers i.e width, height, fill weight 
etc.. 
and I have a textbox in which to determine the specification amount i.e 
25mm, 50mm, 25g etc.. 

This spec is then transferred to TextBox2 when commanded giving me the 
specification:    Width    25mm
                  Height    50mm      
                  Fill Weight    25g    and so on....

As you can see, the spec amounts are not aligned.  Can the field length of 
the specification headers be set at a required length in a way that the 
missing letters would be replaced with spaces? i.e If the field length was 
25 and 'Width' was entered, it would automatically be followed by 20 
spaces, and 'Fill Weight' would be followed by 14 spaces, etc...? If this 
is possible then I honestly don't know where to start.

Stephen





Try this - it may be what you are looking for...

Private Sub btnAddText_Click()

   TextBox2 =3D TextBox2 & ListText & "     " & TextBox1 & vbCrLf

End Sub

Just add the amount of spaces that you want between the quotes...

Kenny
Message #4 by joe.dunn@c... on Wed, 19 Jun 2002 16:38:23 +0000
You can pad out a field with a variable number of characters so that (as
per your example):

Width - length of 5 - would be followed by 20 blanks
Fill Weight - length of 11 - would be followed by 14 blanks

e.g.

NewField = Trim(OldField) & Left(strBlanks, 25 - len(Trim(OldField)))

where

strBlanks is predefined as a string set to blanks

Dim strBlanks as string
strBlanks = "                         "

so you need to take the contents of the field TextBox, parse it and put the
results into TextBox2.
Let me try this tomorrow - I am going home now!

Joe Dunn

*************************************************************************

This e-mail may contain confidential information or be privileged. It is intended to be read and used only by the named
recipient(s). If you are not the intended recipient(s) please notify us immediately so that we can make arrangements for its return:
you should not disclose the contents of this e-mail to any other person, or take any copies. Unless stated otherwise by an
authorised individual, nothing contained in this e-mail is intended to create binding legal obligations between us and opinions
expressed are those of the individual author.

The CIS marketing group, which is regulated for Investment Business by the Financial Services Authority, includes:
Co-operative Insurance Society Limited Registered in England number 3615R - for life assurance and pensions
CIS Unit Managers Limited Registered in England and Wales number 2369965  - for unit trusts and PEPs
CIS Policyholder Services Limited Registered in England and Wales number 3390839 - for ISAs and investment products bearing the CIS
name
Registered offices: Miller Street, Manchester M60 0AL   Telephone  0161-832-8686   Internet  http://www.cis.co.uk   E-mail
cis@c...

CIS Deposit and Instant Access Savings Accounts are held with The Co-operative Bank p.l.c., registered in England and Wales number
990937, P.O. Box 101, 1 Balloon Street, Manchester M60 4EP, and administered by CIS Policyholder Services Limited as agent of the
Bank.

CIS is a member of the General Insurance Standards Council

CIS & the CIS logo (R) Co-operative Insurance Society Limited

********************************************************************************
Message #5 by "cdebiasio@t... on Wed, 19 Jun 2002 17:54:00 +0200 (CEST)
Hi!

Try this:

'*******************************************************************************
*****************************************
' Procedure Function str_PadL(ByVal SourceString As String, ByVal Length As 
Long, Optional ByVal PadChar As String = " ")
' Date      20 August 1993
' Rev.      1997/10/06  Claudio de Biasio   CdB_01  Optional PaddingChar 
parameter
' Rev.      2001/05/31  Claudio de Biasio   CdB_02  Gillette rewrite
' Developer Team 97 [Claudio de Biasio]
' Goal      Return a string with padded chars on the left side
' Return    [String] String with padded chars
'*******************************************************************************
*****************************************

Public Function str_PadL(ByVal SourceString As String, ByVal Length As Long, 
Optional ByVal PadChar As String = " ")

    str_PadL = Right$((String$(Length, PadChar) & SourceString), Length)

End Function

If you need str_PadR and str_PadC, just let me know, although, it can be a nice 
exercise!!! 
Also. In case you just need SPACES, remember you can still use LSET and RSET!!! 
I developed these functions because sometimes I was in need to pad strings with 
something else (e.g. "0", "*", "-"...)

Hope this helps.

   Claudio de Biasio
     Team 97 S.r.l.


Quoting joe.dunn@c...:

> 
> You can pad out a field with a variable number of characters so that
> (as
> per your example):
> 
> Width - length of 5 - would be followed by 20 blanks
> Fill Weight - length of 11 - would be followed by 14 blanks
> 
> e.g.
> 
> NewField = Trim(OldField) & Left(strBlanks, 25 - len(Trim(OldField)))
> 
> where
> 
> strBlanks is predefined as a string set to blanks
> 
> Dim strBlanks as string
> strBlanks = "                         "
> 
> so you need to take the contents of the field TextBox, parse it and put
> the
> results into TextBox2.
> Let me try this tomorrow - I am going home now!
> 
> Joe Dunn
> 
> *************************************************************************
> 
> This e-mail may contain confidential information or be privileged. It is
> intended to be read and used only by the named recipient(s). If you are
> not the intended recipient(s) please notify us immediately so that we
> can make arrangements for its return: you should not disclose the
> contents of this e-mail to any other person, or take any copies. Unless
> stated otherwise by an authorised individual, nothing contained in this
> e-mail is intended to create binding legal obligations between us and
> opinions expressed are those of the individual author.
> 
> The CIS marketing group, which is regulated for Investment Business by
> the Financial Services Authority, includes:
> Co-operative Insurance Society Limited Registered in England number
> 3615R - for life assurance and pensions
> CIS Unit Managers Limited Registered in England and Wales number 2369965
>  - for unit trusts and PEPs
> CIS Policyholder Services Limited Registered in England and Wales number
> 3390839 - for ISAs and investment products bearing the CIS name
> Registered offices: Miller Street, Manchester M60 0AL   Telephone 
> 0161-832-8686   Internet  http://www.cis.co.uk   E-mail cis@c...
> 
> CIS Deposit and Instant Access Savings Accounts are held with The
> Co-operative Bank p.l.c., registered in England and Wales number 990937,
> P.O. Box 101, 1 Balloon Street, Manchester M60 4EP, and administered by
> CIS Policyholder Services Limited as agent of the Bank.
> 
> CIS is a member of the General Insurance Standards Council
> 
> CIS & the CIS logo (R) Co-operative Insurance Society Limited
> 
> 
********************************************************************************
> 
> 
Message #6 by "Leo Scott" <leoscott@c...> on Wed, 19 Jun 2002 10:00:40 -0700
How about setting the font to a fixed width font like Courier and then
aligning it with spaces.

|-----Original Message-----
|From: Stephen Birnie [mailto:beelzebubs_offspring@h...]
|Sent: Wednesday, June 19, 2002 4:27 PM
|To: Access
|Subject: [access] Re: Tab Setting
|
|
|Sorry Kenny that won't work either.
|What I'm trying to do is this:
|
|I have a list of specification headers i.e width, height, fill weight
|etc..
|and I have a textbox in which to determine the specification amount i.e
|25mm, 50mm, 25g etc..
|
|This spec is then transferred to TextBox2 when commanded giving me the
|specification:    Width    25mm
|                  Height    50mm
|                  Fill Weight    25g    and so on....
|
|As you can see, the spec amounts are not aligned.  Can the field length of
|the specification headers be set at a required length in a way that the
|missing letters would be replaced with spaces? i.e If the field length was
|25 and 'Width' was entered, it would automatically be followed by 20
|spaces, and 'Fill Weight' would be followed by 14 spaces, etc...? If this
|is possible then I honestly don't know where to start.
|
|Stephen
|
|
|
|
|
|Try this - it may be what you are looking for...
|
|Private Sub btnAddText_Click()
|
|   TextBox2 =3D TextBox2 & ListText & "     " & TextBox1 & vbCrLf
|
|End Sub
|
|Just add the amount of spaces that you want between the quotes...
|
|Kenny

Message #7 by joe.dunn@c... on Thu, 20 Jun 2002 08:59:43 +0000
re: str_PadL

That looks fine and I would be interested in the str_PadR and str_PadC
functions. What is LSET and RSET?

I use Access versions 2, 97 and 2000 (not XP yet) and have not come across
these functions.

*************************************************************************

This e-mail may contain confidential information or be privileged. It is intended to be read and used only by the named
recipient(s). If you are not the intended recipient(s) please notify us immediately so that we can make arrangements for its return:
you should not disclose the contents of this e-mail to any other person, or take any copies. Unless stated otherwise by an
authorised individual, nothing contained in this e-mail is intended to create binding legal obligations between us and opinions
expressed are those of the individual author.

The CIS marketing group, which is regulated for Investment Business by the Financial Services Authority, includes:
Co-operative Insurance Society Limited Registered in England number 3615R - for life assurance and pensions
CIS Unit Managers Limited Registered in England and Wales number 2369965  - for unit trusts and PEPs
CIS Policyholder Services Limited Registered in England and Wales number 3390839 - for ISAs and investment products bearing the CIS
name
Registered offices: Miller Street, Manchester M60 0AL   Telephone  0161-832-8686   Internet  http://www.cis.co.uk   E-mail
cis@c...

CIS Deposit and Instant Access Savings Accounts are held with The Co-operative Bank p.l.c., registered in England and Wales number
990937, P.O. Box 101, 1 Balloon Street, Manchester M60 4EP, and administered by CIS Policyholder Services Limited as agent of the
Bank.

CIS is a member of the General Insurance Standards Council

CIS & the CIS logo (R) Co-operative Insurance Society Limited

********************************************************************************
Message #8 by "cdebiasio@t... on Thu, 20 Jun 2002 13:07:22 +0200 (CEST)
Hi!!!

Well, I am sending you the code for those other functions at the end of the 
message. 
About LSET and RSET, that you can look for in the standard help file, they're a 
couple of old BASIC functions, used during old times of Random records... 
Basically they grant exactly that - that the content of a string is padded (and 
does not overflow) a fixed amount of chars. E.g.:

sDestination = Space$(20)
LSet sDestination = "Goophy"

gives you 

sDestination := "Goophy              "
(the string with the "new string" left aligned), with Len(sDestination) = 20. 
It can alternatively trim the string, if this is longer than the template:

sDestination = Space$(3)
LSet sDestination = "Scrooge"

gives you

sDestination := "Scr"

RSet is identical, but stuffs chars right-aligned.

I guess only a few of us EVER used those functions, back in 1985-1990, and 
anyway no one uses them anymore. Kind of Let...

These are the functions for padding right and centered:

'*******************************************************************************
*****************************************
' Procedure Function str_PadR(ByVal SourceString As String, ByVal nChars As 
Integer, Optional ByVal PadChar As String = " ") As String
' Date      20 August 1993
' Rev.      1997/10/06  Claudio de Biasio   CdB_01  Optional PaddingChar 
parameter
' Rev.      2001/05/31  Claudio de Biasio   CdB_02  Gillette rewrite
' Developer Team 97 [Claudio de Biasio]
' Goal      Return a string with padded chars on the right side
' Return    [String] String with padded chars
'*******************************************************************************
*****************************************

Public Function str_PadR(ByVal SourceString As String, ByVal Length As Long, 
Optional ByVal PadChar As String = " ") As String

    str_PadR = Left$(SourceString & (String$(Length, PadChar)), Length)

End Function




'*******************************************************************************
*****************************************
' Procedure Function str_PadC(ByVal SourceString As String, ByVal Length As 
Long, Optional ByVal PadChar As String = " ") As String
' Date      20 August 1993
' Rev.      1997/10/06  Claudio de Biasio   CdB_01  Optional PaddingChar 
parameter
' Developer Team 97 [Claudio de Biasio]
' Goal      Return a string with padded chars on the both sides
' Return    [String] String with padded chars
' Notes     VB implementation of xBase PADC function
'*******************************************************************************
*****************************************

Public Function str_PadC(ByVal SourceString As String, ByVal Length As Long, 
Optional ByVal PadChar As String = " ") As String 
    
    If (Length < Len(SourceString)) Then
        str_PadC = Mid$(SourceString, (Len(SourceString) - Length) / 2, Length)
    Else
        SourceString = String$(Length \ 2, PadChar) & SourceString & 
String$((Length + 1) \ 2, PadChar)
        str_PadC = Mid$(SourceString, (Len(SourceString) - Length + 1) / 2, 
Length)
    End If
    
End Function

Cheers,

   Claudio de Biasio
     Team 97 S.r.l.



Quoting joe.dunn@c...:

> 
> re: str_PadL
> 
> That looks fine and I would be interested in the str_PadR and str_PadC
> functions. What is LSET and RSET?
> 
> I use Access versions 2, 97 and 2000 (not XP yet) and have not come
> across
> these functions.
> 
> *************************************************************************
> 
> This e-mail may contain confidential information or be privileged. It is
> intended to be read and used only by the named recipient(s). If you are
> not the intended recipient(s) please notify us immediately so that we
> can make arrangements for its return: you should not disclose the
> contents of this e-mail to any other person, or take any copies. Unless
> stated otherwise by an authorised individual, nothing contained in this
> e-mail is intended to create binding legal obligations between us and
> opinions expressed are those of the individual author.
> 
> The CIS marketing group, which is regulated for Investment Business by
> the Financial Services Authority, includes:
> Co-operative Insurance Society Limited Registered in England number
> 3615R - for life assurance and pensions
> CIS Unit Managers Limited Registered in England and Wales number 2369965
>  - for unit trusts and PEPs
> CIS Policyholder Services Limited Registered in England and Wales number
> 3390839 - for ISAs and investment products bearing the CIS name
> Registered offices: Miller Street, Manchester M60 0AL   Telephone 
> 0161-832-8686   Internet  http://www.cis.co.uk   E-mail cis@c...
> 
> CIS Deposit and Instant Access Savings Accounts are held with The
> Co-operative Bank p.l.c., registered in England and Wales number 990937,
> P.O. Box 101, 1 Balloon Street, Manchester M60 4EP, and administered by
> CIS Policyholder Services Limited as agent of the Bank.
> 
> CIS is a member of the General Insurance Standards Council
> 
> CIS & the CIS logo (R) Co-operative Insurance Society Limited
> 
> 
********************************************************************************
> 
> 
Message #9 by "Gregory Serrano" <SerranoG@m...> on Thu, 20 Jun 2002 14:00:13
Stephen,

The suggestions you're getting for padding are good, but they're not 
addressing a problem.  Actually, one person came very close!

The problem with PADL and PADR is that they work, however, the font 
matters.  You need to use a non-proportionally spaced font in conjunction 
with the padding functions.

If you use Times Roman or Arial, the padding will still be off because 
different letters and the space have different widths (proportionally 
spaced).  If you use something like Courier, then all letters and spaces 
are the exact same width.  Therefore, your padding technique WILL line up 
the words.

Greg

Message #10 by "cdebiasio@t... on Thu, 20 Jun 2002 15:27:24 +0200 (CEST)
Hi!!!

Actually, I noticed how far from the original point we all went. I personally 
replied with the PadXyz functions to address the PADDING problem, not to solve 
the original one. Of course, you're right - a non proportional font is the only 
one way to give those "padding functions" a meaning.

Actually, this problem can be solved IN GENERAL sending a "tabulation" to the 
control - via the SendMessage API. That way it can align columns of text even 
using proportional fonts.

If you have to set tabs in a list box, than use this code:



Option Explicit

Private Const LB_SETTABSTOPS As Long = &H192

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 Sub Form_Load()

   'Initialization of ListBox's tabulations
   Dim lTabArray(0 To 3) As Long

   'Setting tabs. Remember that "Right alignment" can be obtained using a 
negative value

   lTabArray(0) = 0
   lTabArray(1) = -80      
   lTabArray(2) = 85
   lTabArray(3) = 170
   
   'Clear any existing tabs
   Call SendMessage(List1.hWnd, LB_SETTABSTOPS, 0&, ByVal 0&)
   
   'Set list tabstops
   Call SendMessage(List1.hWnd, LB_SETTABSTOPS, 4&, lTabArray(0))

   'Fill the list with items. Set the font for the list to something NOT 
proportional, like Arial
   List1.AddItem "Gee" & vbTab & "1" & vbTab & "Sure!" & vbTab & "Fine!"
   List1.AddItem "Wonderful!" & vbTab & "122" & vbTab & "Can't say.." & vbTab 
& "End of example"
   List1.AddItem "Nice" & vbTab & "1.000.000" & vbTab & "Maybe" & vbTab & "End!"
   List1.AddItem "Terrific!" & vbTab & "124" & vbTab & "What else?" & vbTab 
& "That's it."

End Sub


Didn't want to get into something like this just to keep it simple... but this 
really solves the problem.

    Claudio de Biasio
      Team 97 S.r.l.


Quoting Gregory Serrano <SerranoG@m...>:

> Stephen,
> 
> The suggestions you're getting for padding are good, but they're not 
> addressing a problem.  Actually, one person came very close!
> 
> The problem with PADL and PADR is that they work, however, the font 
> matters.  You need to use a non-proportionally spaced font in
> conjunction 
> with the padding functions.
> 
> If you use Times Roman or Arial, the padding will still be off because 
> different letters and the space have different widths (proportionally 
> spaced).  If you use something like Courier, then all letters and spaces
> 
> are the exact same width.  Therefore, your padding technique WILL line
> up 
> the words.
> 
> Greg
> 
> 
Message #11 by braxis@b... on Thu, 20 Jun 2002 15:05:09 +0100 (BST)
The SendMessage API seems to be one of those 'Magic' functions - I've used it to auto resize columns in
a ListView control.

Where could a find an easily understanable listing of all the things that can be done with this versatile API?

Thanks

Brian

>  from:    "cdebiasio@t..." <cdebiasio@t...>
>  date:    Thu, 20 Jun 2002 14:27:24
>  to:      access@p...
>  subject: Re: [access] Re: Tab Setting
> 
> Hi!!!
> 
> Actually, I noticed how far from the original point we all went. I personally 
> replied with the PadXyz functions to address the PADDING problem, not to solve 
> the original one. Of course, you're right - a non proportional font is the only 
> one way to give those "padding functions" a meaning.
> 
> Actually, this problem can be solved IN GENERAL sending a "tabulation" to the 
> control - via the SendMessage API. That way it can align columns of text even 
> using proportional fonts.
> 
> If you have to set tabs in a list box, than use this code:
> 
> 
> 
> Option Explicit
> 
> Private Const LB_SETTABSTOPS As Long = &H192
> 
> 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 Sub Form_Load()
> 
>    'Initialization of ListBox's tabulations
>    Dim lTabArray(0 To 3) As Long
> 
>    'Setting tabs. Remember that "Right alignment" can be obtained using a 
> negative value
> 
>    lTabArray(0) = 0
>    lTabArray(1) = -80      
>    lTabArray(2) = 85
>    lTabArray(3) = 170
>    
>    'Clear any existing tabs
>    Call SendMessage(List1.hWnd, LB_SETTABSTOPS, 0&, ByVal 0&)
>    
>    'Set list tabstops
>    Call SendMessage(List1.hWnd, LB_SETTABSTOPS, 4&, lTabArray(0))
> 
>    'Fill the list with items. Set the font for the list to something NOT 
> proportional, like Arial
>    List1.AddItem "Gee" & vbTab & "1" & vbTab & "Sure!" & vbTab & "Fine!"
>    List1.AddItem "Wonderful!" & vbTab & "122" & vbTab & "Can't say.." & vbTab 
> & "End of example"
>    List1.AddItem "Nice" & vbTab & "1.000.000" & vbTab & "Maybe" & vbTab & "End!"
>    List1.AddItem "Terrific!" & vbTab & "124" & vbTab & "What else?" & vbTab 
> & "That's it."
> 
> End Sub
> 
> 
> Didn't want to get into something like this just to keep it simple... but this 
> really solves the problem.
> 
>     Claudio de Biasio
>       Team 97 S.r.l.
> 
> 
> Quoting Gregory Serrano <SerranoG@m...>:
> 
> > Stephen,
> > 
> > The suggestions you're getting for padding are good, but they're not 
> > addressing a problem.  Actually, one person came very close!
> > 
> > The problem with PADL and PADR is that they work, however, the font 
> > matters.  You need to use a non-proportionally spaced font in
> > conjunction 
> > with the padding functions.
> > 
> > If you use Times Roman or Arial, the padding will still be off because 
> > different letters and the space have different widths (proportionally 
> > spaced).  If you use something like Courier, then all letters and spaces
> > 
> > are the exact same width.  Therefore, your padding technique WILL line
> > up 
> > the words.
> > 
> > Greg
> > 
> > 
> 

Message #12 by "cdebiasio@t... on Thu, 20 Jun 2002 17:01:59 +0200 (CEST)
Well, SendMessage does what its name says - Sends a Message. So what you need 
is not a "list of things this function can do", but a reference for all the 
Messages used by Windows Systems. That's to say, a reference of API library, 
completed with structures, messages, and so on. 
Years ago there was a set of books from Bantam Publishing, but now I don't 
know. Microsoft online has tons of references, but they're kind of distributed, 
and I guess you'd rather prefer a reference. 
Try to see what other publishers (including Microsoft Press) has got, about 
Windows (98/ME/2000/XP) operating systems. There you can find what you're 
looking for. 
I don't have such a reference right now - I just use online help and browse the 
Internet for answers as problems come up -, but I would like to have one too.

Cheers,

    Claudio de Biasio
      Team 97 S.r.l.

Quoting braxis@b...:

> The SendMessage API seems to be one of those 'Magic' functions - I've
> used it to auto resize columns in a ListView control.
> 
> Where could a find an easily understanable listing of all the things
> that can be done with this versatile API?
> 
> Thanks
> 
> Brian
> 
> >  from:    "cdebiasio@t..." <cdebiasio@t...>
> >  date:    Thu, 20 Jun 2002 14:27:24
> >  to:      access@p...
> >  subject: Re: [access] Re: Tab Setting
> > 
> > Hi!!!
> > 
> > Actually, I noticed how far from the original point we all went. I
> personally 
> > replied with the PadXyz functions to address the PADDING problem, not
> to solve 
> > the original one. Of course, you're right - a non proportional font is
> the only 
> > one way to give those "padding functions" a meaning.
> > 
> > Actually, this problem can be solved IN GENERAL sending a "tabulation"
> to the 
> > control - via the SendMessage API. That way it can align columns of
> text even 
> > using proportional fonts.
> > 
> > If you have to set tabs in a list box, than use this code:
> > 
> > 
> > 
> > Option Explicit
> > 
> > Private Const LB_SETTABSTOPS As Long = &H192
> > 
> > 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 Sub Form_Load()
> > 
> >    'Initialization of ListBox's tabulations
> >    Dim lTabArray(0 To 3) As Long
> > 
> >    'Setting tabs. Remember that "Right alignment" can be obtained
> using a 
> > negative value
> > 
> >    lTabArray(0) = 0
> >    lTabArray(1) = -80      
> >    lTabArray(2) = 85
> >    lTabArray(3) = 170
> >    
> >    'Clear any existing tabs
> >    Call SendMessage(List1.hWnd, LB_SETTABSTOPS, 0&, ByVal 0&)
> >    
> >    'Set list tabstops
> >    Call SendMessage(List1.hWnd, LB_SETTABSTOPS, 4&, lTabArray(0))
> > 
> >    'Fill the list with items. Set the font for the list to something
> NOT 
> > proportional, like Arial
> >    List1.AddItem "Gee" & vbTab & "1" & vbTab & "Sure!" & vbTab &
> "Fine!"
> >    List1.AddItem "Wonderful!" & vbTab & "122" & vbTab & "Can't say.."
> & vbTab 
> > & "End of example"
> >    List1.AddItem "Nice" & vbTab & "1.000.000" & vbTab & "Maybe" &
> vbTab & "End!"
> >    List1.AddItem "Terrific!" & vbTab & "124" & vbTab & "What else?" &
> vbTab 
> > & "That's it."
> > 
> > End Sub
> > 
> > 
> > Didn't want to get into something like this just to keep it simple...
> but this 
> > really solves the problem.
> > 
> >     Claudio de Biasio
> >       Team 97 S.r.l.
> > 
> > 
> > Quoting Gregory Serrano <SerranoG@m...>:
> > 
> > > Stephen,
> > > 
> > > The suggestions you're getting for padding are good, but they're not
> 
> > > addressing a problem.  Actually, one person came very close!
> > > 
> > > The problem with PADL and PADR is that they work, however, the font
> 
> > > matters.  You need to use a non-proportionally spaced font in
> > > conjunction 
> > > with the padding functions.
> > > 
> > > If you use Times Roman or Arial, the padding will still be off
> because 
> > > different letters and the space have different widths
> (proportionally 
> > > spaced).  If you use something like Courier, then all letters and
> spaces
> > > 
> > > are the exact same width.  Therefore, your padding technique WILL
> line
> > > up 
> > > the words.
> > > 
> > > Greg
> > > 
> > > 
> > 
> 
> 
> 
Message #13 by "Leo Scott" <leoscott@c...> on Thu, 20 Jun 2002 18:17:25 -0700
For a VB/VBA Programmer you might want to look at "Visual Basic Programmer's
Guide to the Win32 API" by Dan Appleman.  ISBN 0-672-31590-4.

|-----Original Message-----
|From: cdebiasio@t... [mailto:cdebiasio@t...]
|Sent: Thursday, June 20, 2002 8:02 AM
|To: Access
|Subject: [access] Re: Tab Setting
|
|
|Well, SendMessage does what its name says - Sends a Message. So
|what you need
|is not a "list of things this function can do", but a reference
|for all the
|Messages used by Windows Systems. That's to say, a reference of
|API library,
|completed with structures, messages, and so on.
|Years ago there was a set of books from Bantam Publishing, but now I don't
|know. Microsoft online has tons of references, but they're kind of
|distributed,
|and I guess you'd rather prefer a reference.
|Try to see what other publishers (including Microsoft Press) has
|got, about
|Windows (98/ME/2000/XP) operating systems. There you can find what you're
|looking for.
|I don't have such a reference right now - I just use online help
|and browse the
|Internet for answers as problems come up -, but I would like to
|have one too.
|
|Cheers,
|
|    Claudio de Biasio
|      Team 97 S.r.l.
|
|Quoting braxis@b...:
|
|> The SendMessage API seems to be one of those 'Magic' functions - I've
|> used it to auto resize columns in a ListView control.
|>
|> Where could a find an easily understanable listing of all the things
|> that can be done with this versatile API?
|>
|> Thanks
|>
|> Brian
|>
|> >  from:    "cdebiasio@t..." <cdebiasio@t...>
|> >  date:    Thu, 20 Jun 2002 14:27:24
|> >  to:      access@p...
|> >  subject: Re: [access] Re: Tab Setting
|> >
|> > Hi!!!
|> >
|> > Actually, I noticed how far from the original point we all went. I
|> personally
|> > replied with the PadXyz functions to address the PADDING problem, not
|> to solve
|> > the original one. Of course, you're right - a non proportional font is
|> the only
|> > one way to give those "padding functions" a meaning.
|> >
|> > Actually, this problem can be solved IN GENERAL sending a "tabulation"
|> to the
|> > control - via the SendMessage API. That way it can align columns of
|> text even
|> > using proportional fonts.
|> >
|> > If you have to set tabs in a list box, than use this code:
|> >
|> >
|> >
|> > Option Explicit
|> >
|> > Private Const LB_SETTABSTOPS As Long = &H192
|> >
|> > 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 Sub Form_Load()
|> >
|> >    'Initialization of ListBox's tabulations
|> >    Dim lTabArray(0 To 3) As Long
|> >
|> >    'Setting tabs. Remember that "Right alignment" can be obtained
|> using a
|> > negative value
|> >
|> >    lTabArray(0) = 0
|> >    lTabArray(1) = -80
|> >    lTabArray(2) = 85
|> >    lTabArray(3) = 170
|> >
|> >    'Clear any existing tabs
|> >    Call SendMessage(List1.hWnd, LB_SETTABSTOPS, 0&, ByVal 0&)
|> >
|> >    'Set list tabstops
|> >    Call SendMessage(List1.hWnd, LB_SETTABSTOPS, 4&, lTabArray(0))
|> >
|> >    'Fill the list with items. Set the font for the list to something
|> NOT
|> > proportional, like Arial
|> >    List1.AddItem "Gee" & vbTab & "1" & vbTab & "Sure!" & vbTab &
|> "Fine!"
|> >    List1.AddItem "Wonderful!" & vbTab & "122" & vbTab & "Can't say.."
|> & vbTab
|> > & "End of example"
|> >    List1.AddItem "Nice" & vbTab & "1.000.000" & vbTab & "Maybe" &
|> vbTab & "End!"
|> >    List1.AddItem "Terrific!" & vbTab & "124" & vbTab & "What else?" &
|> vbTab
|> > & "That's it."
|> >
|> > End Sub
|> >
|> >
|> > Didn't want to get into something like this just to keep it simple...
|> but this
|> > really solves the problem.
|> >
|> >     Claudio de Biasio
|> >       Team 97 S.r.l.
|> >
|> >
|> > Quoting Gregory Serrano <SerranoG@m...>:
|> >
|> > > Stephen,
|> > >
|> > > The suggestions you're getting for padding are good, but they're not
|>
|> > > addressing a problem.  Actually, one person came very close!
|> > >
|> > > The problem with PADL and PADR is that they work, however, the font
|>
|> > > matters.  You need to use a non-proportionally spaced font in
|> > > conjunction
|> > > with the padding functions.
|> > >
|> > > If you use Times Roman or Arial, the padding will still be off
|> because
|> > > different letters and the space have different widths
|> (proportionally
|> > > spaced).  If you use something like Courier, then all letters and
|> spaces
|> > >
|> > > are the exact same width.  Therefore, your padding technique WILL
|> line
|> > > up
|> > > the words.
|> > >
|> > > Greg
|> > >
|> > >
|> >
|>
|>
|>
|
|

Message #14 by "Richard Lobel" <richard@a...> on Fri, 21 Jun 2002 22:40:15 -0700
The vbTab in your string is simply a predefined constant. It is not in
the textbox you are setting the tab but rather the string you are
putting into the box. Why don't you define your own constant with as
many spaces as you want and use that in your strings instead.

****original message****
>Is there any way of setting the tab length in a text box? I have a text

box that displays info from a second text box and a list box together. I

want to be able to line up all the data. I am adding a tab between the
two 
texts but because some of the words in the List are longer than others 
they are not being tabbed to the same position for the second word.<

Richard Lobel
President
NoClassroom.com
Live VB Training Over the Internet 
richard@n...
Tel:  (xxx) xxx-xxxx
Fax:  (xxx) xxx-xxxx




  Return to Index