473,325 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Code to determine number of vbTabs to use

Can anyone tell me what algorithm I should use to determine how many tabs to
add to a string.

I have two strings.

I want to add them to a listbox concatenated but with a tab between them.

one tab makes them not line up as string A and B are variable length.

String A is the shortest of the 2 and the Key.

What can I do to determine how many vbTabs to put in between the strings so
they will line up?

thanks

shane
Nov 20 '05 #1
6 1756
* "SStory" <Th*******@TAKETHISSPAMBUSTEROUT.Softhome.net> scripsit:
Can anyone tell me what algorithm I should use to determine how many tabs to
add to a string.

I have two strings.

I want to add them to a listbox concatenated but with a tab between them.

one tab makes them not line up as string A and B are variable length.

String A is the shortest of the 2 and the Key.

What can I do to determine how many vbTabs to put in between the strings so
they will line up?


Why not use a ListView control in details view instead?

- or -

Use PInvoke on 'SendMessage' + 'LB_SETTABSTOPS'. A VB6 sample can be
found here:

<http://www.mvps.org/vbnet/index.html?code/listapi/listrightalign.htm>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Herfried,
Use PInvoke on 'SendMessage' + 'LB_SETTABSTOPS'. A VB6 sample can be
found here: You know, I always thought it odd that the ListBox has a UseTabStops
property, but has no method of setting what the TabStops should be...

If you include the following in the Load event for your form, you will see
that the tabstops default to about "8" or so. Which depending on the OP's
strings lengths may be sufficent to work with.

For x As Integer = 1 To 19
ListBox1.Items.Add((New String("x"c, x) & ControlChars.Tab &
x.ToString()))
Next x
' Make the ListBox display tabs within each item.
ListBox1.UseTabStops = True

Just a thought
Jay
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bq*************@ID-208219.news.uni-berlin.de... * "SStory" <Th*******@TAKETHISSPAMBUSTEROUT.Softhome.net> scripsit:
Can anyone tell me what algorithm I should use to determine how many tabs to add to a string.

I have two strings.

I want to add them to a listbox concatenated but with a tab between them.
one tab makes them not line up as string A and B are variable length.

String A is the shortest of the 2 and the Key.

What can I do to determine how many vbTabs to put in between the strings so they will line up?


Why not use a ListView control in details view instead?

- or -

Use PInvoke on 'SendMessage' + 'LB_SETTABSTOPS'. A VB6 sample can be
found here:

<http://www.mvps.org/vbnet/index.html?code/listapi/listrightalign.htm>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #3
well, Herfried,

I took a data form that was an MS example that has a listbox for lookup and
nav buttons and build a nice inheritable baseform that requires little code
and allows you to override a lot of things and uses a listbox.

In this case I wanted list items to have tabs. So having to make a listview
in this case defeated the purpose, although maybe I need to make another
version that uses a listview instead.... Interesting idea.

I haven't used PInvoke yet.

What object has PInvoke for me to use to call? I assume pinvoke is used to
make a winapi call or something...unmanaged code. I was trying to come up
with some algorithm that would figure so many charachters gets a tab and
more chars less tabs and assumed 8 chars per tab but haven't gotten it to
working yet.

Thanks,

Shane

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bq*************@ID-208219.news.uni-berlin.de...
* "SStory" <Th*******@TAKETHISSPAMBUSTEROUT.Softhome.net> scripsit:
Can anyone tell me what algorithm I should use to determine how many tabs to add to a string.

I have two strings.

I want to add them to a listbox concatenated but with a tab between them.
one tab makes them not line up as string A and B are variable length.

String A is the shortest of the 2 and the Key.

What can I do to determine how many vbTabs to put in between the strings so they will line up?


Why not use a ListView control in details view instead?

- or -

Use PInvoke on 'SendMessage' + 'LB_SETTABSTOPS'. A VB6 sample can be
found here:

<http://www.mvps.org/vbnet/index.html?code/listapi/listrightalign.htm>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #4
Cor
Hi Jay B,

Just a little thing I use in my examples (and only there)
dim x as integer
for x = 1 to 19

I do that because in 2002 this not posible and there are a lot with the
standard edition visiting this newsgroup.

For x As Integer = 1 To 19


(was there a reason why you did start with one?)

But maybe you have other idea's about it, it is more work so maybe I should
change that?

:-)
Cor
Nov 20 '05 #5
Cor,
(was there a reason why you did start with one?) I started with 1, as that is what the sample in MSDN started with, look up
ListBox.UseTabStops for the original sample.

You are correct, keeping the sample at a 2002 level is beneficial for those
who choose not to upgrade.

However I prefer to show current & label as such (I forgot the label).
Showing current may help motivate those people to move to current... Also
the variable is only used in the For loop, so I prefer to scope it in the
For loop.

Just a thought
Jay

"Cor" <no*@non.com> wrote in message
news:eN**************@TK2MSFTNGP12.phx.gbl... Hi Jay B,

Just a little thing I use in my examples (and only there)
dim x as integer
for x = 1 to 19

I do that because in 2002 this not posible and there are a lot with the
standard edition visiting this newsgroup.

For x As Integer = 1 To 19
(was there a reason why you did start with one?)

But maybe you have other idea's about it, it is more work so maybe I

should change that?

:-)
Cor

Nov 20 '05 #6
* "SStory" <Th*******@TAKETHISSPAMBUSTEROUT.Softhome.net> scripsit:
I took a data form that was an MS example that has a listbox for lookup and
nav buttons and build a nice inheritable baseform that requires little code
and allows you to override a lot of things and uses a listbox.

In this case I wanted list items to have tabs. So having to make a listview
in this case defeated the purpose, although maybe I need to make another
version that uses a listview instead.... Interesting idea.

I haven't used PInvoke yet.

What object has PInvoke for me to use to call? I assume pinvoke is used to
make a winapi call or something...unmanaged code. I was trying to come up
with some algorithm that would figure so many charachters gets a tab and
more chars less tabs and assumed 8 chars per tab but haven't gotten it to
working yet.


There is no managed way to set the tabstops (untested):

\\\
Private Declare Auto Function SendMessage Lib "user32.dll" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByRef aint() As Integer _
) As Int32

Private Const LB_SETTABSTOPS As Int32 = &H192
..
..
..
Dim aintTabs() As Integer = {0, 120}
SendMessage(MyListbox.Handle, LB_SETTABSTOPS, 2, aintTabs(0))
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jason | last post by:
I have a number of arrays that are populated with database values. I need to determine which array has the highest ubound out of all the arrays. The array size will always change based on the...
17
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
4
by: Bart Plessers \(artabel\) | last post by:
Hello, I have an asp script that lists the files in a directory: CurrentPATH = "c:\temp\" Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFolder = oFSO.GetFolder(CurrentPATH) Set...
65
by: Skybuck Flying | last post by:
Hi, I needed a method to determine if a point was on a line segment in 2D. So I googled for some help and so far I have evaluated two methods. The first method was only a formula, the second...
3
by: Gaffar | last post by:
Hello, I am Handling a project in ( ASP.NET with C#.NET) in which a module is slow and inefficient. How to optimize the code. Please give me some suggestions regarding this. If you know any...
5
by: Steven Smith | last post by:
I was flicking through the windows accesories programs for some inspiration for todays vb challenge when I came accross the calculator program & thought that looks easy I could do that. However...
11
by: Tim Marshall | last post by:
I use Terry Kreft's & Stephen Lebans colour dialog procedures for users to pick colours for various control properties in certain apps. Is there a way to take the colour code that is displayed in...
3
by: peterhall | last post by:
In VBA an Access module has a find method - works perfectly to find a string inside a module. i'm working in A97 (legacy) systems (large ones) and want to write code that searches all modules so that...
3
by: Hazza | last post by:
Hi, I am using PHP and mysql to create a website. I am fairly new to PHP, and thus am grateful to anyone who helps! Firstly I am running a homepage, that displays additional content if a user...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.