|
-
Jul 31st, 2000, 08:11 AM
#1
Thread Starter
Frenzied Member
When I copy a list of items from a column in Excel or a table in FrontPage and paste them into a multi-line text box in my application, I can then edit them into a paragraph of comma separated items by continuosly pressing in order:
HOME BACKSPACE COMMA SPACEBAR
That puts the items together with a comma and a space between each item.
The problem?
Well, it recently occured to me to try to build a "hotkey" for this repeated action by assigning the four Keys using vbKEY on a KEYDOWN event.
Well, I'm stuck on the vbKeyHome. Why is it that when I actually press this button at runtime, the cursor goes back to the front of the line I am on in the textbox, but when I use the command vbKeyHome in code, the cursor returns to the top line and first character position of the whole textbox?
Does anybody have the answer of a simpler way?
Thanks a lot.
-
Aug 1st, 2000, 10:56 PM
#2
Fanatic Member
The reason it goes to the top line is that your working on the text as a complete block in the textbox, where-as when you are pressing the keys manually your mind is looking at the data in line format NOT block format, so....
instead of using code to press the home key (as when you press that takes the cursor to pos 1) what you need to do is take the code from the clipboard and paste it out to a temporary text file and read it in line by line and add it the target textbox still line by line
Code:
txtFinal.text = txtLine.text & vbCrlf
and you should have no problems.
DocZaf
{;->
-
Aug 2nd, 2000, 03:04 AM
#3
Thread Starter
Frenzied Member
Hi. Thanks for your help.
Actually i came up with another solution yesterday.
My objective was to paste a column into the text box and have it convert to a block of text with a comma and a space separating what used to be individual cell values. So, here is what i did:
I put an invisible text box on the form and a command button. The new text box was not multiline.
So then I said Text2.text = text1.text
when it pastes in, all the return key commands convert to that funny looking character that returns Asc value 13.
SO, then I just sent the text thru a loop that searched for characters that returned value 13 , then replaced those characters with ", " (the comma and a space). Then when the process was over, I deleted the last character of the string (also a return key command) and then
Text1.Text = Text2.Text
It's a bit slow, but it saves a lot of monotonous key repetition and it ends with a good looking text box.
Thanks again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|