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 13429
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,579
Recognized Expert Moderator MVP
** 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.
mshmyob 904
Recognized Expert Contributor
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...?
mshmyob 904
Recognized Expert Contributor
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,579
Recognized Expert Moderator MVP
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?
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 style="display:none;"><input type="hidden" name="change_lang" value="1">
<label for="lang" accesskey="l">== <?= CHOOSE_LANG ?> ==</label></p>
<p class="margin"><select id="lang" name="lang" class="langsection"
onChange="if (this.options.value != 'null')
|
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 labels, datagrids, datalists...
Also, I know you can output directly using Response.Write(). But this places
the output at the beginning of the file.
How can you output the text at a specific place in the HTML code? An example
would be when...
|
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 but it left me with a line carriage return in the file (0d0a)
outfilew.Write(group6)
outfilew.Write(Environment.NewLine)
Note:
|
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 redraw at various intervals ( based
on the timer ). The text is not moving that smoothly, it seems very jerky,
no matter what combination of timings and pixel amounts to move so I have
looked at other code and posts and they all seem to have the...
|
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 english. thanks in advance.
| |
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 style="position:relative;bottom:30px;">abc</div></p>
How can I achieve that using javascript?
|
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, 5999900. If I draw text directly to the graphics object using DrawString then the text comes out fine, however If I first add my string to my GraphicsPath then use the FillPath method of the graphics object the same text is displayed with very poor...
|
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 href="/mumbai/bbb.com>mumbai</a>
then in the anchor tag too the replacement takes place which should not be done..
How to solve this problem?
|
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;
using System.Web;
using System.Data.SqlClient;
using System.Xml;
|
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" >
<table background="images/Layer-7.png" width="677" height="311" alt="content" class="pngimg" />
<tr>
<td> Lorem ipsum dolor sit amet, consectetur adipiscing elit. In a est magna, vel tincidunt nulla. Maecenas ligula enim, pretium id porta...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |