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

text selection..

hi there..
this my first post in this forum, hope you all can help me :)

here the case:
as the user is typing, i wants to capture the word which has just finished being typed -- as signalled when the user presses the space bar.

i.e:
the user type "thisword " (with space), then my program will capture "thisword"(without space) when the user press the space bar.

i use a rich text box object.

need your suggestion..
thanks
Sep 27 '07 #1
5 1285
QVeen72
1,445 Expert 1GB
Hi,

Write this code in LostFocus event of the RichTextBox:

RTextBox1.Text = Trim(RTextBox1.Text)

Regards
Veena
Sep 27 '07 #2
hi veena, thanks for the help..
but your code is not work and didn't give any result to me.

maybe you isn't too clear with what i want, here i explain a bit better:
i have made a simple text editor using a richtextbox object, i need to capture the word which has just finished being typed when the user presses the space bar.

example:
if i type "wordOne " in the RtextBox, my program will capture "wordOne"and do something with that word. when i continue and type "wordTwo " after the "wordOne" word (it's going to be "wordOne wordTwo "), my program will only capture the "wordTwo" word, and so on.

the points is, how to get 1 word on the cursor left side.

any idea for me?? :)
Sep 29 '07 #3
QVeen72
1,445 Expert 1GB
Hi,

Yes, Your problem was not explained clear..
any way Write This Code in KeyPress Event of the RichTextBox:

This code is for TextBox, change it to rich text box..

Expand|Select|Wrap|Line Numbers
  1. Private Sub Text1_KeyPress(KeyAscii As Integer)
  2.     Dim i As Long
  3.     Dim NewWord As String
  4.     If KeyAscii = vbKeySpace Then
  5.         NewWord = ""
  6.         If Trim(Text1.text) <> "" Then
  7.             For i = Len(Text1.text) To 1 Step -1
  8.                 NewWord = Mid(Text1.text, i)
  9.                 If Mid(Text1.text, i, 1) = " " Then
  10.                     Exit For
  11.                 End If
  12.             Next
  13.         End If
  14.         Label3.Caption = NewWord
  15.         MsgBox NewWord
  16.     End If
  17. End Sub
  18.  

Regards
Veena
Sep 29 '07 #4
looks like your code will be work :) thanks..

as i read your code, it will return the last word in richtextbox (sory if i'm wrong ;p).

now, how if we want to capture the word based on cursor position.
here the case:

"one two three four five
six seven eight nine
ten(cursor here)"
it will return "ten".

now:
"one two three four five
six seven (cursor here)eight nine
ten"
it will return "seven".

once again:
"one(cursor here) two three four five
six seven eight nine
ten"
it will return "one".

still signalled by presses the space bar.

thanks any way :)
Oct 2 '07 #5
hi veena,

my problem solved now :)
i try to combine your last code with 2 others code
and it's works :D

thanks for the help..
Oct 6 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Ed Suominen | last post by:
I'm thinking of implementing a real-time collaborative text editor in Python using Twisted. An initial plan is to use a Twisted PB server daemon that accepts user:password:file connections from...
9
by: lkrubner | last post by:
I've got a function, you can see it below, that is being called onmouseup in the textarea on my main form. The idea is to find a selection if possible and store that text in a global variable. I...
5
by: nboutelier | last post by:
Scenario: you enter "foo bar" into a text field... Is it possible through javascript to select/highlight just "foo"? formObject.select() selects all. I need to select only part of the string....
7
by: William Gill | last post by:
Is there a simple way to cut and paste from a tkinter text widget to an entry widget? I know I could create a mouse button event that triggers a popup (message widget) prompting for cut/paste in...
4
by: Adnan Siddiqi | last post by:
Hi Pardon me if I am not making any sense.What I want to know the cordinates of selected text by user so that i can save/retrieve them later.is It possible.I am lookig for both IE and Firefox...
2
by: ahynes | last post by:
HI folks, I'm a chem engineer with no VB programming knowledge (as you'll see from my question!) I want a script to open a .txt file, insert pre-defined text into the start and end of the...
2
by: ahynes | last post by:
HI folks, I need a script to open a .txt file, insert pre-defined text into the start and end of the file, then close teh saved file with a .nc extension. I'd like to have this so I can run it...
1
by: mr k | last post by:
Hi, I wanted to use mail merge with forms but Text form fields are not retained during mail merge in Word, I got the code from Microsoft but it doesn't remember the text form field options such as...
3
by: Dekortage | last post by:
Hi all... I am able to grab the text that a user has selected on a web page, using this code: function moreInfo() { if (!isIE) { var t = window.getSelection(); // act on variable "t";
1
by: wselen | last post by:
Hi everybody, Currently I am working on an function in which I want to tag certain parts of text. This is what I have now : case "djenter": var selection = str; ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.