This is probably a very easy question to answer:
I have been outputting some text to a message box, similar to the following: - strOutput = "---" & Chr(10) & Chr(10)
-
strOutput = strOutput & "VAR:" & AddTabs(1) & Format(rsVar![VAR], "currency")
-
strOutput = strOutput & Chr(10) & Chr(10)
-
strOutput = strOutput & "Position Value:" & AddTabs(1) & Format(rsVar![ValuePosition], "currency") & Chr(10)
-
strOutput = strOutput & "Position Risk:" & AddTabs(1) & Format(rsVar![valueRisk], "currency") & Chr(10)
-
msgbox(strOutput)
Which works fine. I tried outputting the same string (strOutput) in a text box on a form, i.e.: -
txtBox.caption = strOutput
The problem is that rather than creating new lines using chr(10), small boxes appear.
Does anyone know an equivalent to chr(10) that will work when sending a string to a text box?
12 13330
Hi. You are not actually outputting the string to the textbox, but to its associated label (by use of the caption property). As far as I know labels are not intended to display multi-line strings, hence your problem with the line feed.
You should find that the actual text box displays multi-line strings correctly. To set the textbox itself to the string, simply use
txtBox = strOutput
You will need to resize the textbox vertically to see the second and subsequent lines correctly.
-Stewart
ps there is a vb constant vbCrLf which you can use in place of your Chr(10) to insert a complete carriage-return and line-feed combination into the string. You may find that this works reliably if the Chr(10) does not.
NeoPa 32,556
Expert Mod 16PB
** NEWS **
Stewart leaves me nothing to say - AGAIN!
/** NEWS **
I would only stress further that using vbCRLF (and/or associated vbCR and vbLF constants) is a recommended way to refer to these characters. It makes the code more easily readable if nothing else.
Actually Captions on labels CAN be multi lined.
As the previous posts say use the vbCrLF instead of chr(10) and then you MUST set the height of your label to accomodate all the lines. If your height is not set to accomodate all the lines it will just show 1 line or as many as it can show in the label.
I create multi line labels all the time. I also ran your code and substituted vbCRLF and it works for me.
cheers,
This is probably a very easy question to answer:
I have been outputting some text to a message box, similar to the following: - strOutput = "---" & Chr(10) & Chr(10)
-
strOutput = strOutput & "VAR:" & AddTabs(1) & Format(rsVar![VAR], "currency")
-
strOutput = strOutput & Chr(10) & Chr(10)
-
strOutput = strOutput & "Position Value:" & AddTabs(1) & Format(rsVar![ValuePosition], "currency") & Chr(10)
-
strOutput = strOutput & "Position Risk:" & AddTabs(1) & Format(rsVar![valueRisk], "currency") & Chr(10)
-
msgbox(strOutput)
Which works fine. I tried outputting the same string (strOutput) in a text box on a form, i.e.: -
txtBox.caption = strOutput
The problem is that rather than creating new lines using chr(10), small boxes appear.
Does anyone know an equivalent to chr(10) that will work when sending a string to a text box?
Thanks for all your comments.
I have replaced Chr(10) with vbCrLf with the desired results.
However...vbTab is not producing tabs, but those small boxes again...?
I don't think tabbing is supported in a label caption. You would just need to add spaces.
cheers,
Thanks for all your comments.
I have replaced Chr(10) with vbCrLf with the desired results.
However...vbTab is not producing tabs, but those small boxes again...?
NeoPa 32,556
Expert Mod 16PB
Tabs in general (and therefore vbTab in this situation) only has meaning within a defined context. What would you be expecting of a tab within a label?
The difference between Chr(10) and vbCRLF is not simply that one is a constant. Chr(10) is actually equivalent to vbLF rather than vbCRLF (It is a Line-Feed rather than a Character Return / Line Feed combination).
I suspect that whichever control you're using this in (TextBox or Label) has no context defined for Tab characters therefore it won't match what you expect.
Tabs in general (and therefore vbTab in this situation) only has meaning within a defined context. What would you be expecting of a tab within a label?
The difference between Chr(10) and vbCRLF is not simply that one is a constant. Chr(10) is actually equivalent to vbLF rather than vbCRLF (It is a Line-Feed rather than a Character Return / Line Feed combination).
I suspect that whichever control you're using this in (TextBox or Label) has no context defined for Tab characters therefore it won't match what you expect.
I'm trying to display a table of data, aligning the columns using tabs. I'm also outputting the same text to an email, which accepts the tab character. The table is roughly 6 columns by 20 rows.
As NeoPa says, a tab has no meaning without a context. Thirty years ago typewriter teachers used to teach typing students about the use of tabs, and how important they were in lining up numbers within the manually-spaced lines of (monospaced) Courier or similar text.
Tabs are more or less obsolete in powerful word processors such as Word, where the line-oriented left, right, centre and decimal tabs have generally been replaced by the use of tables, where the columns themselves can align text left, centre and right. Even so, Word still has default tabs set every 1/2 in as standard. Whay am I mentioning this? Because if you set up a document with 1/2" tabs, use these to space the text, then someone changes it to 1", say, the document suddenly becomes unreadable.
It is because a tab is effectively an instruction to move the current text location to a defined point that it has no meaning unless the context is defined.
...And all of this is a long-winded way of asking you, as NeoPa has also done - in what context is it meaningful to include tabs in a text control which has no default means of handling the spacing instruction you have included?
-Stewart (the verbose...)
You can use a List Box control for displaying information in columns, yes?
(Sigh) It takes longer to write a reply than it does for the thread context to change, hence I sent then deleted a message which was out of context of the changed thread.
The last poster makes the point that a listbox control can be used to output columns. It can, but with limitations - there is not much in the way of alignment that can be done, for instance. And it does not answer what you need for output via e-mail. I would suggest using a text export which is tab-delimited or using CSV format to output your columns, rather than trying to do this in the message itself. This would be an attachment task, but at least has the advantage that tabs delineate columns, whereas otherwise the interpretation of tabs depends entirely on the application.
In my experience e-mail applications do not do a good job of tabbing, as they impose defaults in the same way as word processors do - arbitrarily. Some columns line up, some don't as they miss the tab point concerned. Some spill into the next column, and so on.
-Stewart
NeoPa 32,556
Expert Mod 16PB
You could try using spaces to format your output. Many text processors use this method even now, especially when no default context is defined. Alternatively, using the same approach, you could use a character other than the space for tabulation formatting (characters frequently used for this include . - _ = * + etc).
PS. Thanks Stewart for that clarification. You translated my message perfectly :)
Thanks for the clarification.
The original context was within an email, wherein a tab character moved in multiples of six character spaces, to the nearest multiple. This made the formatting of the table using tabs a reasonably trivial task. I'll probably try using spaces to format the text within the text box.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Cezary |
last post by:
Hi.
I want to change language on my site online. So, I wrote this:
<form action="<?= preg_replace("/&/", "&", $_SERVER)
?>" method="post" name="change_lang_form">
<p...
|
by: Andrei Pociu |
last post by:
I have a major doubt about outputting text in ASP .NET when using code
behind.
I know most of the output you gain from a code behind file (.aspx.cs) is
outputted to the Webform (.aspx) using...
|
by: Lyle A. Sieren |
last post by:
Hello!
Is there a way to output text in a unix format from vb.net? I am trying to complete a CIM load in Progress and I need the data to be in unix format.
I tried using the following code...
|
by: Bishman |
last post by:
Hi,
I have been trying to get text to scroll smoothly accross a windows form
using GDI+ and a timer. Changing the position of the text by a configurable
amount and calling invalidate to force a...
|
by: xiaawan |
last post by:
Hi Everyone . I am having problem with text align in CSS. I am using <li> element. I want to display text centered vertically i.e. it should be at equal distance from top and bottom. sorry for my bad...
|
by: nskclr |
last post by:
Hi
I add a text using document.selection.createRange().
I want to add a text to the bottom of another text - similar to what we do in HTML.
<p>
xyz
</p>
<p><div...
|
by: NosherRees |
last post by:
I'm using GraphicsPath to draw text onto a graphics object (PictureBox). My graphics object has been scaled so that the top left corner is 400000, 6000000 and the bottom right corner is 400100,...
|
by: padmaneha |
last post by:
How to omit replacement in somepart of text using regular expression?
For ex:
If i want to replace mumbai with mumbai/aaa.com but if i have an anchor tag
<a...
|
by: u8dmtm |
last post by:
I want to output XML from an ASP.Net page and have created the code below:
using System;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;...
|
by: Sirus86 |
last post by:
problem with text and image.Text is overlaying or moving to below image. i design is very complex and i need to include a scroll within the design.
this is what i have so far
div id="content" ...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |