Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Editing multiline textbox

Hi!

I have simple userform with one multiline textbox and 6 checkboxes. My
problem is how to make that checking a checkbox will copy the textbox value
to a new line without deleting the upper line. I tried various things but I
cant avoid the deletion of the upper line (especialy in the case of more then
one checked checkbox).
I will be grateful for any suggestion.

Thanks in advance

Eli
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Editing multiline textbox

I have simple userform with one multiline textbox and 6 checkboxes. My
problem is how to make that checking a checkbox will copy the textbox
value
to a new line without deleting the upper line. I tried various things but
I
cant avoid the deletion of the upper line (especialy in the case of more
then
one checked checkbox).


Copy the "textbox value" to a new line? Where is this new line going?

Did you, perhaps, mean to type "copy the CheckBox Caption property to the
bottom of the TextBox? If not, I think you will need to clarify what is
being copied and to where.

Rick

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Editing multiline textbox

Rick,
Before one of the checkboxes are checked the textbox has one line, with for
example the word - apple. I am asking about the creation of new line inside
the textbox that the word apple will appear with the word Juice for example.
So the textbox after one checked checkbox will be:

apple
apple juice
apple pie (after the seconed checked checkbox)

Eli

"Rick Rothstein (MVP - VB)" wrote:

I have simple userform with one multiline textbox and 6 checkboxes. My
problem is how to make that checking a checkbox will copy the textbox
value
to a new line without deleting the upper line. I tried various things but
I
cant avoid the deletion of the upper line (especialy in the case of more
then
one checked checkbox).


Copy the "textbox value" to a new line? Where is this new line going?

Did you, perhaps, mean to type "copy the CheckBox Caption property to the
bottom of the TextBox? If not, I think you will need to clarify what is
being copied and to where.

Rick


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Editing multiline textbox

Something like:
TextBox1.value=TextBox1.value & " juice"
But that is the same line

Or do you mean:
TextBox1.value=TextBox1.value & vbnewline & "juice"

So what happens when the user uncheck that CheckBox ?
Seems that a ListBox would be more appropriate for your needs.

NickHK

"???" wrote in message
...
Rick,
Before one of the checkboxes are checked the textbox has one line, with

for
example the word - apple. I am asking about the creation of new line

inside
the textbox that the word apple will appear with the word Juice for

example.
So the textbox after one checked checkbox will be:

apple
apple juice
apple pie (after the seconed checked checkbox)

Eli

"Rick Rothstein (MVP - VB)" wrote:

I have simple userform with one multiline textbox and 6 checkboxes. My
problem is how to make that checking a checkbox will copy the textbox
value
to a new line without deleting the upper line. I tried various things

but
I
cant avoid the deletion of the upper line (especialy in the case of

more
then
one checked checkbox).


Copy the "textbox value" to a new line? Where is this new line going?

Did you, perhaps, mean to type "copy the CheckBox Caption property to

the
bottom of the TextBox? If not, I think you will need to clarify what is
being copied and to where.

Rick




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Editing multiline textbox

I have simple userform with one multiline textbox and 6 checkboxes. My
problem is how to make that checking a checkbox will copy the textbox
value
to a new line without deleting the upper line. I tried various things
but
I
cant avoid the deletion of the upper line (especialy in the case of
more
then
one checked checkbox).


Copy the "textbox value" to a new line? Where is this new line going?

Did you, perhaps, mean to type "copy the CheckBox Caption property to the
bottom of the TextBox? If not, I think you will need to clarify what is
being copied and to where.

Before one of the checkboxes are checked the textbox has one line, with
for
example the word - apple. I am asking about the creation of new line
inside
the textbox that the word apple will appear with the word Juice for
example.
So the textbox after one checked checkbox will be:

apple
apple juice
apple pie (after the seconed checked checkbox)


Okay, now I think I see what you are asking. While you could concatenate new
text onto the old text like this...

TextBox1.Text = TextBox1 & vbCrLf & "Next Line"

it is more efficient to use the SelText property instead like this...

TextBox1.SelStart = Len(TextBox1.Text)
TextBox1.SelText = vbCrLf & "Juice"

A word about that first line. If, and this is a big if, the user can
possibly move the text cursor before you add your next line, then you need
it (because the new text is placed wherever the text cursor is located at).
On the other hand, if you were adding your text in a loop, you can omit it.
By the way, you can seed the TextBox with its first line by using the Text
property (you have to start somewhere<g).

Rick



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Editing multiline textbox

NickHK, thanks for your reply.

Can you explain how to do it with a Listbox?

Eli

"NickHK" wrote:

Something like:
TextBox1.value=TextBox1.value & " juice"
But that is the same line

Or do you mean:
TextBox1.value=TextBox1.value & vbnewline & "juice"

So what happens when the user uncheck that CheckBox ?
Seems that a ListBox would be more appropriate for your needs.

NickHK

"???" wrote in message
...
Rick,
Before one of the checkboxes are checked the textbox has one line, with

for
example the word - apple. I am asking about the creation of new line

inside
the textbox that the word apple will appear with the word Juice for

example.
So the textbox after one checked checkbox will be:

apple
apple juice
apple pie (after the seconed checked checkbox)

Eli

"Rick Rothstein (MVP - VB)" wrote:

I have simple userform with one multiline textbox and 6 checkboxes. My
problem is how to make that checking a checkbox will copy the textbox
value
to a new line without deleting the upper line. I tried various things

but
I
cant avoid the deletion of the upper line (especialy in the case of

more
then
one checked checkbox).

Copy the "textbox value" to a new line? Where is this new line going?

Did you, perhaps, mean to type "copy the CheckBox Caption property to

the
bottom of the TextBox? If not, I think you will need to clarify what is
being copied and to where.

Rick





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Editing multiline textbox

Can you explain how to do it with a Listbox?

ListBox1.AddItem "Apple"
ListBox1.AddItem "Juice"

Rick
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Editing multiline textbox

Here's one way, but whether is suitable depends on what the user needs to do
and what you intend to do after.

Private Sub UserForm_Initialize()
With ListBox1
.AddItem "Apple"
End With
End Sub

Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
AddToList ListBox1, CheckBox1.Caption
Else
RemoveFromList ListBox1, CheckBox1.Caption
End If
End Sub

Private Sub CheckBox2_Click()
If CheckBox2.Value = True Then
AddToList ListBox1, CheckBox2.Caption
Else
RemoveFromList ListBox1, CheckBox2.Caption
End If
End Sub

Private Function AddToList(WhichList As MSForms.ListBox, WhichText As
String) As Boolean
With WhichList
.AddItem .List(0) & " " & WhichText
End With
End Function

Private Function RemoveFromList(WhichList As MSForms.ListBox, WhichText As
String) As Boolean
Dim i As Long

With WhichList
For i = 1 To .ListCount - 1
If .List(i) = .List(0) & " " & WhichText Then
.RemoveItem i
Exit Function
End If
Next
End With
End Function

NickHK

"???" wrote in message
...
NickHK, thanks for your reply.

Can you explain how to do it with a Listbox?

Eli

"NickHK" wrote:

Something like:
TextBox1.value=TextBox1.value & " juice"
But that is the same line

Or do you mean:
TextBox1.value=TextBox1.value & vbnewline & "juice"

So what happens when the user uncheck that CheckBox ?
Seems that a ListBox would be more appropriate for your needs.

NickHK

"???" wrote in message
...
Rick,
Before one of the checkboxes are checked the textbox has one line,

with
for
example the word - apple. I am asking about the creation of new line

inside
the textbox that the word apple will appear with the word Juice for

example.
So the textbox after one checked checkbox will be:

apple
apple juice
apple pie (after the seconed checked checkbox)

Eli

"Rick Rothstein (MVP - VB)" wrote:

I have simple userform with one multiline textbox and 6

checkboxes. My
problem is how to make that checking a checkbox will copy the

textbox
value
to a new line without deleting the upper line. I tried various

things
but
I
cant avoid the deletion of the upper line (especialy in the case

of
more
then
one checked checkbox).

Copy the "textbox value" to a new line? Where is this new line

going?

Did you, perhaps, mean to type "copy the CheckBox Caption property

to
the
bottom of the TextBox? If not, I think you will need to clarify what

is
being copied and to where.

Rick







  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Editing multiline textbox

NickHK and Rick

You solved my problem

Thanks a lot!!!

"Rick Rothstein (MVP - VB)" wrote:

I have simple userform with one multiline textbox and 6 checkboxes. My
problem is how to make that checking a checkbox will copy the textbox
value
to a new line without deleting the upper line. I tried various things
but
I
cant avoid the deletion of the upper line (especialy in the case of
more
then
one checked checkbox).

Copy the "textbox value" to a new line? Where is this new line going?

Did you, perhaps, mean to type "copy the CheckBox Caption property to the
bottom of the TextBox? If not, I think you will need to clarify what is
being copied and to where.

Before one of the checkboxes are checked the textbox has one line, with
for
example the word - apple. I am asking about the creation of new line
inside
the textbox that the word apple will appear with the word Juice for
example.
So the textbox after one checked checkbox will be:

apple
apple juice
apple pie (after the seconed checked checkbox)


Okay, now I think I see what you are asking. While you could concatenate new
text onto the old text like this...

TextBox1.Text = TextBox1 & vbCrLf & "Next Line"

it is more efficient to use the SelText property instead like this...

TextBox1.SelStart = Len(TextBox1.Text)
TextBox1.SelText = vbCrLf & "Juice"

A word about that first line. If, and this is a big if, the user can
possibly move the text cursor before you add your next line, then you need
it (because the new text is placed wherever the text cursor is located at).
On the other hand, if you were adding your text in a loop, you can omit it.
By the way, you can seed the TextBox with its first line by using the Text
property (you have to start somewhere<g).

Rick


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Textbox and multiline text Mats Samson Excel Worksheet Functions 0 September 18th 07 08:18 PM
Multiline textbox for data entry אלי Excel Programming 2 June 12th 07 11:50 AM
Userform Textbox multiline Vs format in worksheet Jim May Excel Programming 4 October 16th 05 10:15 PM
UserForm; Textbox; Multiline; NonPrintable Characters sa3214[_2_] Excel Programming 3 November 3rd 04 03:46 PM
Multiline textbox.. Can you have multiple font colors within? bdcrisp[_14_] Excel Programming 3 December 12th 03 12:51 PM


All times are GMT +1. The time now is 04:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"