473,396 Members | 1,754 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,396 software developers and data experts.

TextBox1.Lines(0)

A simple query:

I have a textbox with multiline=true. Also there is a button1. In button1's
click the code written is

textbox1.lines(0) = "Microsoft"
textbox2.lines(1) = "Visual Basic"

Hope you understand what I am trying to achieve. In Textbox1, on line1 I
want to put "Microsoft" and on the second line I want to put "Visual Basic".
However, when I run this code it doesn't work (and raises an execption).

Could you please tell me what's wrong here............and what's the
alternative?

Thanks in advance!
Nov 20 '05 #1
4 6911
This is in continuation of my previous post.

Now, if I change the code as:

TextBox1.Text = "Microsoft" & Chr(13)

TextBox1.Text = TextBox1.Text & "Visual Basic"

MsgBox(TextBox1.Lines(0))

MsgBox(TextBox1.Lines(1))

Now first message box shows "Microsoft" and second message box shows "Visual
Basic". This implies that "Micorsoft" is stored in Line0 and "Visual Basic"
is stored in Line1 of TextBox1.

However on the screen on TextBox1 it doesn't show them on separate line. In
fact both are separated by "|" character.

"I_AM_DON_AND_YOU?" <us**@domain.com> wrote in message
news:OY**************@TK2MSFTNGP09.phx.gbl...
A simple query:

I have a textbox with multiline=true. Also there is a button1. In button1's click the code written is

textbox1.lines(0) = "Microsoft"
textbox2.lines(1) = "Visual Basic"

Hope you understand what I am trying to achieve. In Textbox1, on line1 I
want to put "Microsoft" and on the second line I want to put "Visual Basic". However, when I run this code it doesn't work (and raises an execption).

Could you please tell me what's wrong here............and what's the
alternative?

Thanks in advance!

Nov 20 '05 #2
"I_AM_DON_AND_YOU?" <us**@domain.com> schrieb
This is in continuation of my previous post.

Now, if I change the code as:

TextBox1.Text = "Microsoft" & Chr(13)

TextBox1.Text = TextBox1.Text & "Visual Basic"

MsgBox(TextBox1.Lines(0))

MsgBox(TextBox1.Lines(1))

Now first message box shows "Microsoft" and second message box shows
"Visual Basic". This implies that "Micorsoft" is stored in Line0 and
"Visual Basic" is stored in Line1 of TextBox1.

However on the screen on TextBox1 it doesn't show them on separate
line. In fact both are separated by "|" character.


Here, no "|" is displayed when I execute your code. I see
"MicrosoftVisualBasic". However, I get the same text in the two Msgboxes.

Why don't you type in two lines in the textbox and examine the separator?
Use

TextBox1.Text = "Microsoft" & vbCrLf & "Visual Basic"

or Environment.Newline.

BTW, if you intend to concatenate more strings, check out
System.Text.Stringbuilder.

--
Armin

Nov 20 '05 #3
* "I_AM_DON_AND_YOU?" <us**@domain.com> scripsit:
Now, if I change the code as:

TextBox1.Text = "Microsoft" & Chr(13)

TextBox1.Text = TextBox1.Text & "Visual Basic"

MsgBox(TextBox1.Lines(0))

MsgBox(TextBox1.Lines(1))

Now first message box shows "Microsoft" and second message box shows "Visual
Basic". This implies that "Micorsoft" is stored in Line0 and "Visual Basic"
is stored in Line1 of TextBox1.

However on the screen on TextBox1 it doesn't show them on separate line. In
fact both are separated by "|" character.


You will have to use 'ControlChars.NewLine' or 'Environment.NewLine' to
separate the lines.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
You can assign a new string() instance to the Lines property:

textbox1.Lines = new string() {"Microsoft", "Visual Basic"}

--
Johan Stenberg (MSFT), VB .NET Team
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| From: "I_AM_DON_AND_YOU?" <us**@domain.com>
| Subject: TextBox1.Lines(0)
| Date: Sun, 19 Oct 2003 21:47:00 -0700
| Lines: 18
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <OY**************@TK2MSFTNGP09.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: ppp-67-125-114-188.dialup.irvnca.pacbell.net
67.125.114.188
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:148297
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| A simple query:
|
| I have a textbox with multiline=true. Also there is a button1. In
button1's
| click the code written is
|
| textbox1.lines(0) = "Microsoft"
| textbox2.lines(1) = "Visual Basic"
|
| Hope you understand what I am trying to achieve. In Textbox1, on line1 I
| want to put "Microsoft" and on the second line I want to put "Visual
Basic".
| However, when I run this code it doesn't work (and raises an execption).
|
| Could you please tell me what's wrong here............and what's the
| alternative?
|
| Thanks in advance!
|
|
|

Nov 20 '05 #5

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

Similar topics

3
by: polarz | last post by:
I'm having trouble getting items from different classes to display in my textBox. e.g. private void button2_Click(object sender, System.EventArgs e) { someData sd = new someData();...
5
by: Hareth | last post by:
Is there a way to take a text, from a textbox & later passwordChar the text. I'm not using a masked textbox. I tried: textBox1.PasswordChar = '*'; but this didn't change my text. I know how...
7
by: al | last post by:
Greetings all, I use request.form("textbox1") to get data back to page, dim str as string str = request.form("textbox1").tostring But str is always empty after refresh???? I use asp.net...
4
by: Ken Soenen | last post by:
The code below illustrates my problem which is: I'm trying to access the TEXT from TextBox1 which is on Form1. Line "aa = Form1.TextBox1.Text" produces the error--Reference to a non-shared member...
5
by: Pohihihi | last post by:
Why can't the following work when it has a set property defined? this.textBox1.Size.Width = 25; I get error Cannot modify the return value of 'System.Windows.Forms.Control.Size' because it is...
1
by: emailseshu | last post by:
Hi, Iam trying to check the Client Side CallBack Feature in ASP.NET Iam able to call th RaiseCallbackEvent from the Client Side Javascript Function but when I go to the debug mode to check the...
3
by: Mark Ivey | last post by:
VS.Net 2002 - Visual Basic I am pretty new to VB in general, and I am having a bit of difficulty finding the right method or property to link a textbox to a filelistbox. Here is the...
9
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i'm trying to use the onblur client-side event to get the value of TextBox1 but can't seem to nail down the syntax. can someone please help? thanks, rodchar
2
by: zhang | last post by:
I want to click a button and TextBox1 show the content of the file "1.txt" but failed why?? Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
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...
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...

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.